I'm trying to create an ADODB recordset, but I don't think its working because my RecordCount is always -1.
I've set my CursorType to adOpenStatic, but I still get -1.
I've set my CursorLocation to adUseClient, but I still get -1.
Per another post in this forum, I created an ADODB.Error object. When I try to access its Count property, I receive "Ole Object: Object does not exist, or period is used instead of a comma"
Normally, I use RS = DB.Execute(SQLString). I was experiencing timeouts, so I switched to using ADODB.Command (see below). Since I've never done it this way before, I'm assuming that is the root source of my problem. I'm hoping another set of eyes might help.
It's always something stupid, so what stupid thing have I done this time? - for now let's assume that vstrServer, vstrDatabase, and vstrTable all have valid values:
vstrConnection = "driver={SQL Server};server=":vstrSQLServer:";database=":vstrDatabase:";Trusted_Connection=TRUE;"
; Connect to the SQL database
vobjDatabase = ObjectCreate("adodb.connection")
vobjDatabase.Open = (vstrConnection)
vstrHostName = 'jdoe-laptop'
vstrSQLString = "SELECT * FROM ":vstrTable;:" WHERE [HostName] = '":vstrHostName:"' AND [DateRemoved] IS NOT NULL"
vobjADOCmd = ObjectOpen("ADODB.Command")
vobjADOCmd.ActiveConnection = vobjDatabase
vobjADOCmd.CommandText = vstrSQLString
vobjADOCmd.CommandTimeout = 120
vobjRS = ObjectCreate("ADODB.recordset")
vobjRS.CursorLocation = 3 ;adUseClient
vobjRS.CursorType = 3 ;adStaticOpen
vcolSQLErr = CreateObject('ADODB.Error')
vobjRS = vobjADOCmd.Execute()
If vobjSQLErr.Count > 0 Then
Pause("Notice",vobjSQLErr.Number,@CRLF,vobjSQLError.Description)
End If