What is the problem with my query below?? I keep getting an error.

Question:

Does anyone have an example query to run against an slx db? I’m getting an error using the following:

Sub SLX_Test()

Set objConn = CreateObject(“ADODB.Connection”)
Set objCmd = CreateObject(“ADODB.Command”)
Set objRS = CreateObject(“ADODB.Recordset”)

objConn.ConnectionString = “Provider=SLXOLEDB.1;Integrated Security=True;Initial Catalog=slxcat;Data Source=myslxserver;Extended Properties=PORT=1706;LOG=ON;Location=;Mode=ReadWrite”

objCmd.CommandText = “SELECT * FROM TICKET WHERE TICKETID=’001-00-025850′”

objRS.Open objCmd

While Not objRS.EOF
MsgBox objRS(“AREA”)
objRS.MoveNext
Wend

objRS.Close
objConn.Close
Set objRS = Nothing
Set objCmd = Nothing
Set objConn = Nothing
End Sub

But I get an error: Run-time error ‘3709’: The connection cannot be used to perform this operation. It is either closed or invalid in this context.

 

Answer:

The error message that you are getting is because you are never opening a connection.
After you set the ConnectionString property, you need to open the connection:
objConn.Open

Towards the end you have remembered to “close” the connection, but as stated, you never opened it to begin with.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!