BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

editing and updating existing records in sql database

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
ginte
Guest





PostPosted: Mon Apr 19, 2004 11:19 am    Post subject: editing and updating existing records in sql database Reply with quote



 i 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://delphi.newswhat.com
Back to top
Mike Walsh
Guest





PostPosted: Mon Apr 19, 2004 12:46 pm    Post subject: Re: editing and updating existing records in sql database Reply with quote




Quote:
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;




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



Back to top
Bill Todd (TeamB)
Guest





PostPosted: Mon Apr 19, 2004 1:45 pm    Post subject: Re: editing and updating existing records in sql database Reply with quote



Use the debugger to view the actual SQL statement you are trying to
execute and I think you will see the problem. If not, post the
statement that the debugger shows here.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
Back to top
Bill Todd (TeamB)
Guest





PostPosted: Tue Apr 20, 2004 4:47 pm    Post subject: Re: editing and updating existing records in sql database Reply with quote

As I said in my last message, please post the value of the SQL
property of your query component as shown by the debugger just before
the statement is executed.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
Back to top
ginte
Guest





PostPosted: Tue Apr 20, 2004 6:22 pm    Post subject: Re: editing and updating existing records in sql database Reply with quote

Quote:
Use the debugger to view the actual SQL statement you are trying to
execute and I think you will see the problem. If not, post the
statement that the debugger shows here.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)


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://delphi.newswhat.com

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.