TMSScript questions
Posted: Mon 06 Dec 2010 14:42
Hi
I am trying to use TMSScript to perform a load of inserts into a table, but I cannot seem to find any examples of how to use the component, and the help file is not really very helpfull either..
I want to do a bunch of INSERT INTO's so I have the following:
for i := 0 to list.count - 1 do
begin
msScript.sql.add('INSERT INTO MYTABLE');
msScript.sql.add('(FIELD1, FIELD2, FIELD3)');
msScript.sql.add('VALUES');
msScript.sql.add('(:parm1, :parm2, :parm3)');
msScript.Params.parambyName('parm1').asInteger := list.intvalue;
msScript.Params.parambyName('parm2').asDateTime := list.dateTimeValue;
msScript.Params.parambyName('parm3').asString := list.StrValue;
end;
When I run it I get exception "parameter "parm1" not found.
Am I using the script component the correct way?
Is there a way I can parse the SQL for the parameters? On the TMSQuery I set Paramcheck := true..
The thing is, I want to insert thousands of records, based on a list, and I figured the quickest way was to send a script to the MS SQL server and let it do the rest from there... ?
Best regards
Jens Fudge
I am trying to use TMSScript to perform a load of inserts into a table, but I cannot seem to find any examples of how to use the component, and the help file is not really very helpfull either..
I want to do a bunch of INSERT INTO's so I have the following:
for i := 0 to list.count - 1 do
begin
msScript.sql.add('INSERT INTO MYTABLE');
msScript.sql.add('(FIELD1, FIELD2, FIELD3)');
msScript.sql.add('VALUES');
msScript.sql.add('(:parm1, :parm2, :parm3)');
msScript.Params.parambyName('parm1').asInteger := list.intvalue;
msScript.Params.parambyName('parm2').asDateTime := list.dateTimeValue;
msScript.Params.parambyName('parm3').asString := list.StrValue;
end;
When I run it I get exception "parameter "parm1" not found.
Am I using the script component the correct way?
Is there a way I can parse the SQL for the parameters? On the TMSQuery I set Paramcheck := true..
The thing is, I want to insert thousands of records, based on a list, and I figured the quickest way was to send a script to the MS SQL server and let it do the rest from there... ?
Best regards
Jens Fudge