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 

How to make a query in run time?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO)
View previous topic :: View next topic  
Author Message
Zé Paulo
Guest





PostPosted: Fri Feb 25, 2005 9:44 am    Post subject: How to make a query in run time? Reply with quote




Hello

I want to Do updates in Oracle DB Using Delphi at run Time!
How can I Put de names of the tables and of the fields in the SQL commad?
My problem are With "table_name","column_name" and "parameter"!

I have this procedure:

procedure UpdateDB(query: TQuery; table_name, column_name, parameter, param_value, value: String);
Begin
With query do begin
with SQL do begin
query.Close;
SQL.Clear;
Add('UPDATE "table_name" SET "column_name"=:value WHERE "parameter"=:param_value');
query.ParamByName('value').AsString := value;
query.ParamByName('param_value').AsString := param_value;
query.Prepare;
query.ExecSQL;
End;
End;
End.

Errors:
Table does not exist or Invalid field Name

Thanks
Back to top
Sunil Furtado
Guest





PostPosted: Fri Feb 25, 2005 10:50 am    Post subject: Re: How to make a query in run time? Reply with quote



Try

add('update '+table_name+' set '+colunm_name+'=:value') etc

Sunil

Quote:
procedure UpdateDB(query: TQuery; table_name, column_name, parameter,
param_value, value: String);
Begin
With query do begin
with SQL do begin
query.Close;
SQL.Clear;
Add('UPDATE "table_name" SET "column_name"=:value WHERE
"parameter"=:param_value');
query.ParamByName('value').AsString := value;
query.ParamByName('param_value').AsString := param_value;
query.Prepare;
query.ExecSQL;
End;
End;
End.



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO) 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.