在VBS

2016-07-26 47 views
0
實現xp_sendmail的
ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=mydb;Data Source=myserver" 
Set dbconn = CreateObject("ADODB.Connection") 
dbconn.Open ConnectionString 

DIM cmd 
SET cmd = server.CreateObject("ADODB.Command") 
SET cmd.ActiveConnection = Connection 

cmd.CommandText = "xp_sendmail" 
cmd.CommandType = 4 

cmd.Parameters("@Recipients") = "[email protected]" 
cmd.Parameters("@Subject") = "Test" 
cmd.Parameters("@message") = "Test" 

cmd.Execute 

我的劇本給我一個錯誤:在VBS

Object required: 'server'

任何幫助將不勝感激。謝謝!

+0

嘗試刪除「服務器」。因爲您正在通過WScript/CScript運行腳本。 –

+0

嗨,它給了一個錯誤:Object Required:ActiveConnection –

+0

也許你打算'dbconn'而不是'Connection'。 –

回答

0

查看here瞭解爲什麼以及如何。添加參數。

+0

@Ekkehard嗨,我讀過的文件,但是當我用這個 cmd.parameters.Append cmd.CreateParameter( 「收件人」,adVarChar,adParamInput,50, 「[email protected]」) 它給了我錯誤800A0BB9參數是錯誤的類型..... –

+0

您是否定義了廣告*常量? –