TMSScript questions

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Posts: 31
Joined: Mon 12 Jan 2009 08:37

TMSScript questions

Post by JensFudge » Mon 06 Dec 2010 14:42


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
msScript.sql.add('INSERT INTO MYTABLE');
msScript.sql.add('(FIELD1, FIELD2, FIELD3)');
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;

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

Devart Team
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 07 Dec 2010 14:24

TMSScript doesn't allow to use parameters, because it is used to execute several SQL statements one by one. Also it allows to save script to a file and execute a script from file using the TMSScript.ExecuteFile method. It parses the script and executes statements one after another.

Post Reply