i am trying to use parameterized queries with ADO. Executing the Command object throws the error:
Must declare the variable '@filename'
i declare the parameter @filename using CreateParameter/Append:
sql := 'INSERT INTO Sqm(Filename, data) VALUES(@filename, @data)';
command := CoCommand.Create;
command.Set_ActiveConnection(Connection.ConnectionObject);
command.Set_CommandText(sql);
command.Set_CommandType(adCmdText);
command.Parameters.Append(Command.CreateParameter('@filename', adLongVarWChar, adParamInput, -1, Filename));
command.Parameters.Append(Command.CreateParameter('@data', adLongVarWChar, adParamInput, -1, xml);
command.Execute({out}recordsAffected, EmptyParam, adCmdText or adExecuteNoRecords);
What am i doing wrong?
:instead of@before the params in the query. And remove the @ from where you add the parameters.?in the query where you put the variable namevalues (?, ?). I'm a couple of hours away from a computer so I can't verify that it will work yet.