Using Delphi 7 ADO components the following code snippet works to retrieve a row from a SQL DB table named 'Item' where the column field is an integer. The result is displayed in a DBGrid.
ADOQuery1.Prepared := True;
with ADOQuery1 do
SQL.Text := 'SELECT * FROM Item WHERE BinLocation= 2001126';
Active := True;
How can I retrieve a row where the variable is a string and the column field is set as a nvarchar. I tried ADOQuery1.FieldByName('Ite
ng followed by the query but the program returns an error 'ItemLookupCode field not found'.
Without the .AsString statement to modify the flowing query;
'SQL.Text := 'SELECT * FROM Item WHERE ItemLookupCode= T-23RF';
the code returns the error 'Conversion failed when converting the nvarchar value #2472 to data type int.'
I'm not sure I understand the SQL conversion issue other than the code is apparently trying to use strings to retrieve a variable that is an integer. I need help in creating a query statement that will allow retreiving rows using strings in the WHERE clause?