none
VBScript ADODB.Open fails with error 800S0BB( RRS feed

  • Question

  • I have used this type of SQL access many times before, successfully. However, I am at a dead end as to why this fails. Here is very scaled down code that fails on DBRecordset.Open.  I display the connection string, and it is correct, and I can monitor in SQL Profiler and see the sa login to the Database.  But on the next line, DBRecordset.Open, I get this error.

    Would greatly appreciate some help!



    Set Args = WScript.Arguments

    Const DBConnectString = "Provider=SQLOLEDB.1;Data Source=RC-SRV\RANCH1;Initial Catalog=Merch;user id ='sa';password='Passw0rd'"
    Set DBCommand = CreateObject("ADODB.Command" )
    Set DBRecordset = CreateObject("ADODB.RecordSet")
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Call LookupBatch()
    WScript.Quit

    Sub LookupBatch()
        Set DBConn = CreateObject("ADODB.Connection")
        MsgBox DBConnectString
        DBConn.Open DBConnectString
        DBRecordset.Open"SELECT * FROM Batch", DB-Connect
        If DBRecordset.EOFThen
            MsgBox("No Batch Record not found!")
            ExitSub
            Else
            If DBRecordset.Fields.Item(3) = "Open"Then
            MsgBox(DBRecordset.Fields.Item(1) & ", Found")
            EndIf
        EndIf
        DBConnect.Close
        Set DBConnect = Nothing    

    EndSub

    Friday, July 6, 2018 1:40 AM

Answers

  • The variables seem confused. Should DB-Connect in the recordset Open statement be DBConn? And you close DBConnect, but it is never opened. Maybe DBConn.

    Edit: Just guessing, but could the "S" in the error number be "5"? And the "BB" might be "88".


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)


    Friday, July 6, 2018 1:19 PM
    Moderator

All replies

  • There is no such error and the error number referenced is impossible.  Did you type it wrong.


    \_(ツ)_/

    Friday, July 6, 2018 3:04 AM
  • The variables seem confused. Should DB-Connect in the recordset Open statement be DBConn? And you close DBConnect, but it is never opened. Maybe DBConn.

    Edit: Just guessing, but could the "S" in the error number be "5"? And the "BB" might be "88".


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)


    Friday, July 6, 2018 1:19 PM
    Moderator
  • Image of error

    Sorry, I did not insert the image of the error correctly.

    Friday, July 6, 2018 3:18 PM
  • THANK YOU Richard!  Sometimes I can't see the forest for the trees...

    Corrected code works!!

    Sub LookupBatch()
        Set DBConn = CreateObject("ADODB.Connection")
        MsgBox DBConnectString
        DBConn.Open DBConnectString
        DBRecordset.Open"SELECT * FROM Batch", DBConn
        If DBRecordset.EOFThen
            MsgBox("No Batch Record not found!")
            ExitSub
            Else
            If DBRecordset.Fields.Item(3) = "Closed"Then
            MsgBox(DBRecordset.Fields.Item(1) & ", Found")
            EndIf
        EndIf
        DBConn.Close
        Set DBConn = Nothing    

    EndSub

    Friday, July 6, 2018 3:35 PM
  • You are welcome. Glad it worked.

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Friday, July 6, 2018 4:52 PM
    Moderator