Use Parameters in TLiteQuery
Posted: Sun 27 Jan 2013 14:18
I am creating a login form and I need to set the parameters of a query component through the code. How should I do that (both the parameters are UnicodeStrings)?
Discussion forums for open issues and questions concerning database tools, data access components and developer tools from Devart
https://forums.devart.com/
Code: Select all
LiteConnection1.Options.UseUnicode := True;
LiteConnection1.Connect;
LiteQuery1.SQL.Text := 'select :p1';
LiteQuery1.ParamByName('p1').AsString := Edit1.text;
LiteQuery1.Open;
Code: Select all
LiteQuery1.SQL.Text := 'select :p1 where 1<>1';
LiteQuery1.ParamByName('p1').AsInteger := 1;
LiteQuery1.Open;
ShowMessage(VarToStr(LiteQuery1.IsEmpty)); //True
ShowMessage(VarToStr(LiteQuery1.RecordCount = 0)); //True
Code: Select all
ShowMessage(VarToStr(LiteQuery1.IsEmpty));
Code: Select all
uname=admin;passw=admin
Code: Select all
this->LiteQuery1->ParamByName("uname")->AsString = uname; //admin
this->LiteQuery1->ParamByName("passw")->AsString = pwd; //admin
ShowMessage(VarToStr(this->LiteQuery1->IsEmpty()));
Code: Select all
this->LiteQuery1->ParamByName("uname")->AsString = uname; //admin
this->LiteQuery1->ParamByName("passw")->AsString = pwd; //admin
this->LiteQuery1->Open;
ShowMessage(VarToStr(this->LiteQuery1->IsEmpty()));
ShowMessage(VarToStr(this->LiteQuery1->RecordCount));
assert((this->LiteQuery1->RecordCount = 0) = this->LiteQuery1->IsEmpty());