Question

hi im working on delphi 10 and sybase.

Im having this issue 2 days ago and i've tried a lot of things. i set the adoconnection properties in build, searh my db and its ready. I can insert,delete and update but when im trying to make a select x from y where z the output is COLUMN Y NOT FOUND

when i do a :

select * from administradores 

it work,but the one i need dont. My code is this one.

ADOQuery1.Close ;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Text:='SELECT usu_administrador,pass_administrador from administradores  where usu_administrador='+Edit1.Text+'';
ADOQuery1.Open;

i already tried SQL syntax error ,open fields editor and it dont even have fields. That post it exactly what happen to me, but that solution didnt work for me.

Please,could someone help me?

Was it helpful?

Solution

You should really use parameters in your queries

ADOQuery1.SQL.Text:='SELECT usu_administrador, pass_administrador ' +
      ' from administradores  where usu_administrador = :paramadminname';
ADOQuery1.ParamByName('paramadminname').Value := Edit1.Text;

Also, the reason why your query didn't work was that the value in Edit1 must be in quotes for it to work in your SQL

ADOQuery1.SQL.Text:='SELECT usu_administrador,pass_administrador from administradores  where usu_administrador='+QuotedStr(Edit1.Text);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top