I am failing to find the right way to execute a param query in MySQL
I am using the following code, where cmd param and cn are ADODB objects (Command, Parameter and Connection)
Dim pkc As String
sql = "SELECT * FROM Accions WHERE keyclient = @kc"
cmd.ActiveConnection = cn
cmd.CommandText = sql
pkc = "AMC"
Set param = cmd.CreateParameter("@kc", adVarChar, adParamInput, 12, pkc)
cmd.Parameters.Append param
cmd.CommandType = adCmdText
Set rs = cmd.Execute
cmd.CommandType = adCmdText
Set rs = cmd.Execute
the snippet executes, but the rs recordset is empty, which is wrong.
Any hints on this please? I have seen posts around telling to use '?' instead of '@', but I am failing. Maybe is not a good idea using Mysql param queries from VBA/ADODB?
thanks
I am using the following code, where cmd param and cn are ADODB objects (Command, Parameter and Connection)
Dim pkc As String
sql = "SELECT * FROM Accions WHERE keyclient = @kc"
cmd.ActiveConnection = cn
cmd.CommandText = sql
pkc = "AMC"
Set param = cmd.CreateParameter("@kc", adVarChar, adParamInput, 12, pkc)
cmd.Parameters.Append param
cmd.CommandType = adCmdText
Set rs = cmd.Execute
cmd.CommandType = adCmdText
Set rs = cmd.Execute
the snippet executes, but the rs recordset is empty, which is wrong.
Any hints on this please? I have seen posts around telling to use '?' instead of '@', but I am failing. Maybe is not a good idea using Mysql param queries from VBA/ADODB?
thanks