Board index » delphi » ADO insert error

ADO insert error

Hello,

I am using delphi 5 enterprise version.  I am trying to insert information using store procedure. Please see attached code and store procedure.  I am getting error when I am trying to insert blank data, fdob.text is empty;

error --> 'raised exception class EOleException with message 'Application uses a value of the wrong type for the current operation'

Any help will be highly appreciated.

Thanks.
====
  with dm1.insertADOquery do
    begin
      close;

      Sql.clear;
      sql.add('EXECUTE BANKER_AGENT_SCAN.DBO.FILE_INFORMATION ');
      sql.add(':IFIRSTNAME,:ILASTNAME,:IDOB,:ISSN,:IPOLICYNUMBER,:IIDATE,:IIMAGE,:IDINDEX,:ICOMPANYCODE,');
      sql.add(':IPAGECOUNT,:IPID,:IUSER_INDEX');

      parameters[0].Value := trim(fFirstName.text);
      parameters[1].Value := trim(FLastName.text);
      parameters[2].Value := trim(fDOB.text);
      parameters[3].Value := trim(fSSN.text);
      parameters[4].Value := trim(fCustomField.text);
      parameters[5].Value := DateTimeToFileDate(date);
      istream.LoadFromFile('C:\othr.tif');
      parameters[6].LoadFromStream(istream,ftblob);
      parameters[7].Value := ldindex;

      if FCompanyname2.text = '' then
        parameters[8].Value :=1
      else
        parameters[8].Value :=LCOMP_INDEX;

      parameters[9].Value := pagecount;
      if ppid=0 then
        parameters[10].Value := ''
      else
        parameters[10].value := ppid;

      parameters[11].Value := piece(frmLogon.getUserinfo,'/',1);

      OPEN;

      if (recordcount > 0) then
        begin
          ppid := FieldByName('RPID').asinteger;
          pdocindex := FieldByName('RUINDEX').asinteger;
          btndeldoc.enabled := true;
        end;
    end;
==========
CREATE PROCEDURE [FILE_INFORMATION] (@ifirstname VARCHAR(25),
@ilastname VARCHAR(25),
@idob DATETIME,
@issn VARCHAR(9),
@ipolicynumber VARCHAR(25),
@iidate INTEGER,
@iimage IMAGE,
@idindex INTEGER,
@icomp_index INTEGER,
@ipagecount INTEGER,
@ifoundpid INTEGER,
@iuser_index INTEGER)
AS

--DECLARE @foundpid INTEGER;
DECLARE @errorcode INTEGER;

--EXECUTE @foundpid = SEARCH_PID @ifirstname,@ilastname,@idob,@issn,@ipolicynumber,@iidate;

IF ((@ifoundpid IS NULL) AND (@ifirstname IS NOT NULL) AND (@ilastname IS NOT NULL) AND (@idob IS NOT NULL) AND (@issn IS NOT NULL))
    set @ifoundpid = (SELECT PID FROM PINFO WHERE ((FIRSTNAME=@ifirstname) and (LASTNAME=@ilastname) and (SSN=@issn) and (DOB=@idob)));

IF ((@Ifoundpid IS NULL) AND (@ilastname IS NOT NULL) AND (@idob IS NOT NULL) AND (@issn IS NOT NULL))
      set @ifoundpid = (SELECT PID FROM PINFO WHERE ((LASTNAME=@ilastname) and (SSN=@issn) and (DOB=@idob)));    

IF ((@ifoundpid IS NULL) AND (@ilastname IS NOT NULL)  AND (@issn IS NOT NULL))
      set @ifoundpid = (SELECT PID FROM PINFO WHERE ((LASTNAME=@ilastname) and (SSN=@issn)));

--  INSERT NEW INFO
IF (@ifoundpid IS NULL)
  BEGIN
       INSERT INTO PINFO(FIRSTNAME,LASTNAME,DOB,SSN,POLICYNUMBER,IDATE,COMP_INDEX) VALUES(@ifirstname,@ilastname,@idob,@issn,@ipolicynumber,@iidate,@icomp_index)
      SET @ifoundpid = @@IDENTITY      
  END

IF (@ifoundpid IS NOT NULL)
 BEGIN
   INSERT INTO UNMATCH(PID,DINDEX,DIMAGE,IDATE,PAGECOUNT,USER_INDEX) VALUES (@ifoundpid,@idindex,@iimage,@iidate,@ipagecount,@iuser_index);
   SELECT @@IDENTITY AS RUINDEX,@ifoundpid AS RPID
 END
ELSE
  select @errorcode=0;

=======

 

Re:ADO insert error


Any particular reason you don't use TADOCommand? Try it!

rb

Quote
"bob" <b...@idx.com> wrote in message news:3c62887b$1_1@dnews...
>   with dm1.insertADOquery do
>     begin
>       close;

>       Sql.clear;
>       sql.add('EXECUTE BANKER_AGENT_SCAN.DBO.FILE_INFORMATION ');

sql.add(':IFIRSTNAME,:ILASTNAME,:IDOB,:ISSN,:IPOLICYNUMBER,:IIDATE,:IIMAGE,:
IDINDEX,:ICOMPANYCODE,');
Quote
>       sql.add(':IPAGECOUNT,:IPID,:IUSER_INDEX');

Other Threads