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 

Easy Question D2006 SQL with Params

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





PostPosted: Thu Jul 20, 2006 5:17 am    Post subject: Easy Question D2006 SQL with Params Reply with quote



Hi, I'm trying to do an insert with Parameters but the values are not
inserted on the SQL Statement maybe is an easy error but I didn't found it.

Here is the code

SQLAddInv.SQL.Clear;
SQLAddInv.SQL.Add('INSERT INTO customers (custkey,custname,addr1)');
SQLAddInv.SQL.Add('VALUES (:Custkey, :CustName, :addr1)');
SQLAddInv.ParamByName('Custkey').Value := Vcustkey;
SQLAddInv.ParamByName('CustName').Value := VCustname;
SQLAddInv.ParamByName('addr1').Value := Vaddr1;
SQLAddInv.SQL.SaveToFile('C:\rbs\Invadd.sql');
try
SQLAddInv.ExecSQL(True);
Back to top
Dan Palley
Guest





PostPosted: Thu Jul 20, 2006 8:21 pm    Post subject: Re: Easy Question D2006 SQL with Params Reply with quote



"Arquimides" <arquimedes (AT) science (DOT) net> wrote in message
news:44beca42$1 (AT) newsgroups (DOT) borland.com...
Quote:
Hi, I'm trying to do an insert with Parameters but the values are not
inserted on the SQL Statement maybe is an easy error but I didn't found
it.

Here is the code

SQLAddInv.SQL.Clear;
SQLAddInv.SQL.Add('INSERT INTO customers (custkey,custname,addr1)');
SQLAddInv.SQL.Add('VALUES (:Custkey, :CustName, :addr1)');
SQLAddInv.ParamByName('Custkey').Value := Vcustkey;
SQLAddInv.ParamByName('CustName').Value := VCustname;
SQLAddInv.ParamByName('addr1').Value := Vaddr1;
SQLAddInv.SQL.SaveToFile('C:\rbs\Invadd.sql');
try
SQLAddInv.ExecSQL(True);

The params won't be saved to the file with the SQL statement -- they're
replaced at execute time by the SQL engine. Are you seeing an error
somewhere?

Dan
Back to top
Robert
Guest





PostPosted: Mon Jul 24, 2006 8:10 am    Post subject: Re: Easy Question D2006 SQL with Params Reply with quote



You have not given the parameters a type.
I have always found this to be essential.

ie.

TParam.Datatype = ftString;

Regards,

Robert.

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:44bf9ff2$1 (AT) newsgroups (DOT) borland.com...
Quote:
"Arquimides" <arquimedes (AT) science (DOT) net> wrote in message
news:44beca42$1 (AT) newsgroups (DOT) borland.com...
Hi, I'm trying to do an insert with Parameters but the values are not
inserted on the SQL Statement maybe is an easy error but I didn't found
it.

Here is the code

SQLAddInv.SQL.Clear;
SQLAddInv.SQL.Add('INSERT INTO customers (custkey,custname,addr1)');
SQLAddInv.SQL.Add('VALUES (:Custkey, :CustName, :addr1)');
SQLAddInv.ParamByName('Custkey').Value := Vcustkey;
SQLAddInv.ParamByName('CustName').Value := VCustname;
SQLAddInv.ParamByName('addr1').Value := Vaddr1;
SQLAddInv.SQL.SaveToFile('C:\rbs\Invadd.sql');
try
SQLAddInv.ExecSQL(True);

The params won't be saved to the file with the SQL statement -- they're
replaced at execute time by the SQL engine. Are you seeing an error
somewhere?

Dan
Back to top
Dmitry Arefiev
Guest





PostPosted: Wed Jul 26, 2006 4:14 pm    Post subject: Re: Easy Question D2006 SQL with Params Reply with quote

Hello !

Quote:
You have not given the parameters a type.
I have always found this to be essential.

No, that is not required. Because, first assign of
parameter value will implicitly set parameter type
according to the assigned value type.

Regards,
Dmitry

--
Dmitry Arefiev - www.da-soft.com
AnyDAC - Oracle, MySQL, MSSQL, MSAccess, IBM DB2, Sybase
ASA, DbExpress, ODBC freeware data access framework
gs-soft AG - www.gs-soft.com
SAPx - Delphi to SAP R/3 direct access
Saphir - SAP R/3 metadata at your fingertips
MetaBase - ERWIN model in Delphi applications
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress) 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.