Vb脚本到db echo结果

时间:2012-01-01 18:31:54

标签: sql vbscript plesk

我在我的托管服务器上有这个脚本,而plesk的调度程序将结果返回给服务器,因为这只是优先,如何回显结果,以便plesk向我发送输出?

Const DB_CONNECT_STRING = "Provider=SQLOLEDB.1;Data Source=server;Initial 
Catalog=db;user id ='user';password='password'"
Set myConn = CreateObject("ADODB.Connection")
Set myCommand = CreateObject("ADODB.Command" )
myConn.Open DB_CONNECT_STRING
Set myCommand.ActiveConnection = myConn
myCommand.CommandText = "select COUNT (*)  FROM [Table].[dbo].[User]"
myCommand.Execute

myConn.Close

1 个答案:

答案 0 :(得分:0)

这可能有效:

...
myCommand.CommandText = "select COUNT (*) AS CNT FROM [Table].[dbo].[User]"
myCommand.Execute

Do Until myCommand.Eof = True
    WScript.echo myCommand("CNT")
    myCommand.MoveNext
Loop

myConn.Close

我参考了下面的页面(日文):

http://www.happy2-island.com/vbs/cafe02/capter00604.shtml