Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

Application Server

Query script code

  • Last UpdatedJul 22, 2024
  • 1 minute read

Use the following sample code for the Query script.

DIM Connection as aaDBClient.aaDBConnection;

DIM Command as aaDBClient.aaDBCommand;

'Create a connection object with the connection string.

LogMessage("Creating connection");

Connection = aaDBAccess.CreateConnection("Data Source=localhost;Initial Catalog=AdventureWorks;Integrated Security=true");

'Create a command object, with a SQL statement.

LogMessage("Creating a command object");

Command = Connection.CreateCommand("Select * from Production.Product WHERE ProductNumber = @ProductNumber", aaDBCommandType.SqlStatement, true);

'We used a parameter to specify the value for the ProductNumber field, so initialize it.

Command.SetCharParameterByName("ProductNumber", me.PartNumber, aaDBParameterDirection.Input, 50);

'Everything is ready, let's execute the command async.

LogMessage("Executing command async");

DIM ResultCode as integer;

ResultCode = Command.ExecuteAsync();

if ResultCode <> 0 then

'Failed to start async execution, report the reason.

LogMessage("Got error " + ResultCode + " executing command async");

else

'Execution started, identify the command by ID, for use later.

LogMessage("Command async execution started successfully");

me.CommandID = Command.GetID();

'Allow the Process script to run.

me.ProcessCommand = true;

endif;

'Reset for next time

me.ReadCommand = false;

TitleResults for “How to create a CRG?”Also Available in