Board index » cppbuilder » Parameter question

Parameter question


2005-07-12 12:05:12 AM
cppbuilder114
Hi,
I use the following code:
String SQL = "PARAMETERS name Text(255);"
SQL += "SELECT ID FROM tblClient WHERE clientName = name";
qry->SQL->Clear();
qry->SQL->Add(SQL);
qry->Parameters->ParamByName("name") = "Test";
qry->ExecSQL();
When I execute this code I get the following error:
Parameter 'name' not found
What I am doing wrong?
Thanks in advance
 
 

Re:Parameter question

Hi,
I use the following code:
String SQL = "PARAMETERS name Text(255);"
SQL += "SELECT ID FROM tblClient WHERE clientName = name";
qry->SQL->Clear();
qry->SQL->Add(SQL);
qry->Parameters->ParamByName("name") = "Test";
qry->ExecSQL();
When I execute this code I get the following error:
Parameter 'name' not found
What I am doing wrong?
Thanks in advance
 

Re:Parameter question

ParamByName recognizes parameters in form :paramName - select ID from
tblClient where clientName = :name. Try qry->Parameters->Refresh() after
assigning SQL, you may want to set ParamCheck = false if you do not use
:paramName notation. BTW, your syntax is for MS Jet (MS Access) only.
//------------------------------------------
Regards,
Vassiliev V. V.
www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"Pieter" < XXXX@XXXXX.COM >сообщи?сообщила ?новостях следующе?
Quote

Hi,

I use the following code:

String SQL = "PARAMETERS name Text(255);"
SQL += "SELECT ID FROM tblClient WHERE clientName = name";
qry->SQL->Clear();
qry->SQL->Add(SQL);
qry->Parameters->ParamByName("name") = "Test";

qry->ExecSQL();

When I execute this code I get the following error:
Parameter 'name' not found

What I am doing wrong?

Thanks in advance

 

{smallsort}

Re:Parameter question

Quote
String SQL = "PARAMETERS name Text(255);"
SQL += "SELECT ID FROM tblClient WHERE clientName = name";
qry->SQL->Clear();
qry->SQL->Add(SQL);
qry->Parameters->ParamByName("name") = "Test";
qry->ExecSQL();
try starting parameter name with a ':' ...
SQL += "SELECT ID FROM tblClient WHERE clientName = :name";
qry->SQL->Clear();
qry->SQL->Add(SQL);
qry->Parameters->ParamByName("name") = "Test";
Steve