Reputation: 9
I wanted to call a query that I have created in mysql. It is working in through navicat interface. I am trying to access this query via vb6 I get "Runtime Error 91 object variable or with block variable not set"
My Code vb6:
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim SqlCmd As ADODB.Command
con.Open "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Port=3306;Database=databasename;Username=user;password=pw"
Set SqlCmd = New ADODB.Command
SqlCmd.ActiveConnection = con
SqlCmd.CommandType = adCmdStoredProc
SqlCmd.CommandText = "Stock Movement"
Set rs = sqlcms.Execute
I am not sure on the con.open what is missing?
Thank you in advance
Upvotes: 0
Views: 551
Reputation: 16348
You're calling con.Open
but you haven't instantiated the object yet.
Change Dim con As ADODB.Connection
to
Dim con As New ADODB.Connection
Upvotes: 2