Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving To A Database

Status
Not open for further replies.

patlim88

Programmer
May 14, 2002
22
0
0
US
Hi:

I'm trying to save a field to an Access database. I dropped a TQuery and TUpdateSQL with the appropriate SQL statements.

The application will compile and run and when i click the save button the app acts like it works but when i check the database the record has not been modified (a record already exists in the table.) Does anyone know what is going on?

The below is the code when the save button is clicked:

procedure TForcedCall.btnSaveClick(Sender: TObject);
begin

if (Utility.Modified) then
CallBackQ.FieldByName('BACKCOMP').NewValue:=Utility.Text;

StatBar.Panels[1].Text:='Modified';

RC := chkSaveMessage(Memo1, SaveDialog1);
ForcedCall.Caption:=SaveDialog1.FileName;
Utility.text := '';
ResetBools;
end;

Thanks.

 
Why don't you make use of the dbedit component, that way the database will take cary of updating, and you don't need to syncronize a tedit with a database field.

Use a TQuery, set the requestlive property to true , put a Dbedit and link it to the appropriate field.


In your forced call button, key in CallBackQ.post.
Steven van Els
SAvanEls@cq-link.sr
 
Trychanging the CallBackQ.FieldByName('BACKCOMP').NewValue:=Utility.Text;
to:
CallBackQ.FieldByName('BACKCOMP').AsString:=Utility.Text;
 
I tried using both approaches above and when I try to save information I get the error message EDatabaseError with message CallackQ: Dataset not in edit or insert mode. CallBackQ:TQuery.

Can you tell me what I'm doing wrong. I'm guessing my SQL is wrong in the TQuery portion.

Pat

By the way CallBackQ:TQuery.
 
Have you tried:
f (Utility.Modified) then
begin
CallBackQ.Edit;
CallBackQ.FieldByName('BACKCOMP').NewValue:=Utility.Text;
CallBackQ.Post;
end;

BTW - the statement:
StatBar.Panels[1].Text:='Modified';
is executed everytime regradless of the result of the "if" statement.
 
mgauss:

Using a TEdit textbox and changing the code per the above the application is reacting like it did in my first message.

Any more ideas?

Thanks.

Pat
 
I'm using the following code:

procedure TForcedCall.btnSaveClick(Sender: TObject);
begin
if (Utility.Modified) then
CallBackQ.FieldByName('BACKCOMP').NewValue:=Utility.Text;
try
CallBackUPD.Apply(ukModify);
MessageDlg('Update Successful',mtInformation, [mbOK],0);
except
MessageDlg('Possible error updating database',
mtWarning,[mbOK],0);
RC := chkSaveMessage(Memo1, SaveDialog1);
ForcedCall.Caption:=SaveDialog1.FileName;
Memo1.text := '';
Utility.text := '';

ResetBools;

end; // try
end;

Now I'm getting the message, EDBEngineError with message 'Table does not exist. ORA-00942: table or view does not exist.

Any ideas?

Pat
 
The above code works! I had an error in my sql.

Thanks.

Pat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top