Board index » delphi » SQL Insert - Type Mismatch error

SQL Insert - Type Mismatch error

Hi all

I am trying to use a simple INSERT INTO statement to insert some data into a
table.  The format in Delphi 4 C/S [service pack 2] is the following:

     WITH qQuantity DO
     BEGIN
          SQL.Clear;
          SQL.Add('INSERT INTO "AssemblyParts.DB"           ');
          SQL.Add('   (Assembly_ID, Parts_ID,               ');
          SQL.Add('    Assembly_Quantity, Assembly_Price)   ');
          SQL.Add('VALUES (:AAA, :BBB, :CCC, :DDD)          ');

          Params[0].AsString   := AssemblyID;
          Params[1].AsString   := PartsID;
          Params[2].AsInteger  := TheQuantity;
          Params[3].AsCurrency := TotalPrice;

          Prepare;
          ExecSQL;
     END;

On the ExecSQL statement, it returns with a message indicating "Type
Mismatch" error coming out of the DBEngine.  The following are the
declarations for the paramaters:-

AssemblyID and PartsID --> String
TheQuantity --> Integer
TotalPrice --> Currency

I have had two major errors.  The first one is Type Mismatch and the second
was a "List Index Out Of Bounds (0)" message which now seems to have
disappeared.  I have tried using a TQuery component for the job as well as a
rxQuery component - both with the same results.  I upgraded some time ago to
BDE 5.01 as well.

Any suggestions will be greatly appreciated.

Please cc a copy to mbos...@global.co.za

Thank you

Malcolm Bosman

 

Re:SQL Insert - Type Mismatch error


You can only use parameters in the WHERE clause of a query. You will have to
embed the values as variables in your Add calls.

Bill

--
Bill Todd
(Sorry but TeamB cannot answer questions received via email)
(Remove nospam from my email address to contact me for any other reason)

Other Threads