我想运行以下 VB 脚本并连接到一些 SQL 服务器,并运行以下查询来计算行数。然后将该值保存到一个变量中,我以后可以使用它。
我究竟做错了什么??
Dim tempSQLCount
tempSQLCount = 0
Const DB_CONNECT_STRING = "Provider=SQLOLEDB.1;Data Source=someServer;Initial Catalog=DB;Integrated Security=SSPI"
Set sqlConnection = CreateObject("ADODB.Connection")
Set sqlRecordSet = CreateObject("ADODB.Recordset")
sqlConnection.Open DB_CONNECT_STRING
Set sqlQuery = CreateObject("ADODB.Command" )
sqlQuery.ActiveConnection = sqlConnection
sqlQuery.CommandText = "SELECT COUNT(*) FROM DB.dbo.Task"
sqlQuery.Execute
tempSQLCount = sqlRecordSet
Wscript.Echo sqlRecordSet
sqlRecordSet.Close
Set sqlRecordSet = nothing
sqlConnection.Close
Set sqlConnection = nothing