Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 02-10-2017, 04:51 AM
sktamrkar sktamrkar is offline
Member
 
Join Date: Oct 2013
Posts: 66
Default Error on Executing SQL Command

GM Exprrts,
I Have the following code on button_click event:-
procedure TForm1.btnAddClick(Sender: TObject);
begin
btnGRN.Enabled:=True;
with ADOQuery1 do begin
Active:=False;
SQL.Clear;
SQL.Add('Insert into LogInDet(Roll_no,Password,Stud_Name,FatherName) Values(edtRN.Text,edtPswrd.Text,edtSName.Text,edtF name.Text)');
ExecSQL;
end;
ADOTable1.Refresh;
end;

But got the error :-




Plz help me on this error

Thnx
Sandeep Kumar
Attached Images
File Type: jpg Error1.jpg (37.2 KB, 4 views)
Reply With Quote
  #2  
Old 02-10-2017, 09:40 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,203
Default

Your query doesn't translate the values. But I would always suggest using parameters:
Code:
AdoQuery1.SQL.Text := 'Insert into LogInDet
    (Roll_no,Password,Stud_Name,FatherName) Values(:Roll_no,:Password,:Stud_Name,:FatherName)';

AdoQuery1.ParamByName('Roll_no').AsInteger := StrToInt(edtRN.Text); // assuming it's int???
AdoQuery1.ParamByName('Password').AsString := edtPswrd.Text;
AdoQuery1.ParamByName('Stud_Name').AsString := edtSName.Text;
AdoQuery1.ParamByName('FatherName').AsString := edtFname.Text;

AdoQuery1.ExecSQL();
But your main problem was that you didn't pass the values of the TEdit's but it's name. And you forgot to quote your values (for string). Therefor, the parameter solution is easier and much more readable.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 08:52 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2017, vBulletin Solutions, Inc.