editing and updating existing records in sql database

editing and updating existing records in sql database

Post by gint » Tue, 20 Apr 2004 20:19:27



have created a a table in my database called deathclaims. This table
keeps track of the information regarding death claims reported.

My problem comes in when i try to edit an existing record. I am able to
edit but when i try to update the changes i have made , the following
exception is raised:
'Project infinity.exe raised exception class EDBEngineError with
message 'General Sql error. line 1: Incorrect syntax near 'MNUMBER'.'.

following is the code i am using to update my changes:


procedure TfrmMemberDetails.cmdupdate1Click(Sender: TObject);
begin
if not (qrydeath.State in [dsEdit, dsInsert]) then
qrydeath.open;
qrydeath.edit;

if (qrydeath.State in [dsEdit, dsInsert]) Then
begin
DBExecute('UPDATE deathclaims ' +
'SET Mnumber =
mnum.text,Snumber=snum.text,Ddate=dtpdd.DateTime,Rdate=dtprd.DateTime,Caus
e=txtcause.text' +
'WHERE Mnumber = mnum.text');
end;
end;


end.



what is wrong with my code? please help


grant

ere

--- posted by geoForum on http://www.yqcomputer.com/
 
 
 

editing and updating existing records in sql database

Post by Mike Wals » Tue, 20 Apr 2004 21:46:04


grant,

I don't know what DBExecute is, but you are passing to the it a string that
contains the names of Delphi components. I'm assuming that you want that
procedure to execute the statement? Your statement should read more line

'update DeathClaims set ' +
' MNumber = ' + mnum.text +
', SNumber = ' + snum.text

etc

Mike Walsh

 
 
 

editing and updating existing records in sql database

Post by gint » Thu, 22 Apr 2004 03:22:02

>Use the de *** to view the actual SQL statement you are trying to

i have done as you said and following is the error message coming out:

Error Message : General SQL error. : Invalid column name 'SDDDDF'.
Location : TGroupBox
Module Name : TfrmMain
User Name : User, Demo

'SDDDDF' this is the value i tried to enter on one of the textboxes
called txtcause

below is the called used:

procedure TfrmMemberDetails.cmdupdate1Click(Sender: TObject);
begin
if not (qrydeath.State in [dsEdit, dsInsert]) then
qrydeath.open;
qrydeath.edit;

if (qrydeath.State in [dsEdit, dsInsert]) Then
begin
DBExecute('UPDATE deathclaims SET ' + ' Mnumber = '+ mnum.text
+ ',Snumber=' + snum.text + ',Dddate1= '+ datetostr( ddeath.DateTime)
+ ' ,Rddate1= '+ datetostr(rdeath.DateTime)+' ,Cause= ' + txtcause.text
+ ' WHERE Mnumber = ' + mnum.text +'');




end;
end;


end.


help please

grant

ere

--- posted by geoForum on http://www.yqcomputer.com/