• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 811
  • Last Modified:

insert a rocord to oracle table with delphi adocommand component

i have a table with this specification in oracle
create table a1(name varchar2(8));
 i wanna insert  a record  from a delphi adocommand component to this record


  with ADOCommand1 do begin

   CommandText := 'INSERT INTO a1 ' +
       'VALUES (:v1)';
   CommandType := cmdText      ;
   Parameters.ParamByName('v1').Value := edit1.text;
   Execute
  end;
but this error occur arguments are of wrong type ,are out of acceptable range ,...
but after this message record inserted
0
mhyassin
Asked:
mhyassin
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
what about adding "FetchParms" method:

  with ADOCommand1 do begin

   CommandText := 'INSERT INTO a1 ' +
       'VALUES (:v1)';
   CommandType := cmdText      ;
   FetchParams;
   Parameters.ParamByName('v1').Value := edit1.text;
   Execute
  end;
0
 
mhyassinAuthor Commented:
this component does not have fetchparams method????
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
sorry... looks like I misread an article, and you actually need to call the parsesql method:

with ADOCommand1 do begin
   Command.Text := 'INSERT INTO a1 VALUES (:v1)';
   CommandType := cmdText      ;
   parameters.parsesql(command.text,true);
   Parameters.ParamByName('v1').Value := edit1.text;
   Execute
  end;

http://www.delphi3000.com/articles/article_3800.asp?SK=
0
 
developmentguruCommented:
I just use a TADOQuery and call it's ExecSQL method.  B y the way, I think your SQL command should be:

insert into a1 (name) values (:v1)

Let me know how it goes.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now