Call Stored Procedure from Navision (DotNet Variable)

 

SQLCommand := SQLCommand.SqlCommand();
SQLCommand.CommandType := SQLCommand.CommandType.StoredProcedure;
SQLConnection := SQLConnection.SqlConnection(‘Server=’+’SERVERNAME’+’;’
+ ‘Database=’+’DB Name’+’;’
+ ‘Uid=’+’UID’+’;’
+ ‘Pwd=’+’PWD’+’;’);
SQLConnection.Open;

SQLCommand.CommandText(‘Metro_InsertUpdateOrderInfoEventTriggered’);
SQLCommand.Connection := SQLConnection;

SqlParamCycleCode := SqlParamCycleCode.SqlParameter();
SqlParamCycleCode.ParameterName := ‘@P1’;
SqlParamCycleCode.DbType := SQLDbType.String;
SqlParamCycleCode.Direction := SqlParamCycleCode.Direction.Input;
SqlParamCycleCode.Value:= eventcode;
SQLCommand.Parameters.Add(SqlParamCycleCode);

SqlParamCycleCode := SqlParamCycleCode.SqlParameter();
SqlParamCycleCode.ParameterName := ‘@P2’;
SqlParamCycleCode.DbType := SQLDbType.String;
SqlParamCycleCode.Direction := SqlParamCycleCode.Direction.Input;
SqlParamCycleCode.Value:= 0;
SQLCommand.Parameters.Add(SqlParamCycleCode);

SqlParamCycleCode := SqlParamCycleCode.SqlParameter();
SqlParamCycleCode.ParameterName := ‘@P3’;
SqlParamCycleCode.DbType := SQLDbType.String;
SqlParamCycleCode.Direction := SqlParamCycleCode.Direction.Input;
SqlParamCycleCode.Value:= 0;
SQLCommand.Parameters.Add(SqlParamCycleCode);

SqlParamCycleCode := SqlParamCycleCode.SqlParameter();
SqlParamCycleCode.ParameterName := ‘@P4’;
SqlParamCycleCode.DbType := SQLDbType.String;
SqlParamCycleCode.Direction := SqlParamCycleCode.Direction.Input;
SqlParamCycleCode.Value:= 0;
SQLCommand.Parameters.Add(SqlParamCycleCode);

SqlParamCycleCode := SqlParamCycleCode.SqlParameter();
SqlParamCycleCode.ParameterName := ‘@P5’;
SqlParamCycleCode.DbType := SQLDbType.String;
SqlParamCycleCode.Direction := SqlParamCycleCode.Direction.Input;
SqlParamCycleCode.Value:= WebUserId;
SQLCommand.Parameters.Add(SqlParamCycleCode);

SqlParamCycleCode := SqlParamCycleCode.SqlParameter();
SqlParamCycleCode.ParameterName := ‘@P6’;
SqlParamCycleCode.DbType := SQLDbType.String;
SqlParamCycleCode.Direction := SqlParamCycleCode.Direction.Input;
SqlParamCycleCode.Value:= NoOfOrder;
SQLCommand.Parameters.Add(SqlParamCycleCode);

SqlParamCycleCode := SqlParamCycleCode.SqlParameter();
SqlParamCycleCode.ParameterName := ‘@P7’;
SqlParamCycleCode.DbType := SQLDbType.String;
SqlParamCycleCode.Direction := SqlParamCycleCode.Direction.Input;
SqlParamCycleCode.Value:= TriggerModule;
SQLCommand.Parameters.Add(SqlParamCycleCode);

SqlParamCycleCode := SqlParamCycleCode.SqlParameter();
SqlParamCycleCode.ParameterName := ‘@P8’;
SqlParamCycleCode.DbType := SQLDbType.String;
SqlParamCycleCode.Direction := SqlParamCycleCode.Direction.Input;
SqlParamCycleCode.Value:= TriggerSource;
SQLCommand.Parameters.Add(SqlParamCycleCode);
SqlParamCycleCode := SqlParamCycleCode.SqlParameter();
SqlParamCycleCode.ParameterName := ‘@ActionUser’;
SqlParamCycleCode.DbType := SQLDbType.String;
SqlParamCycleCode.Direction := SqlParamCycleCode.Direction.Input;
SqlParamCycleCode.Value:= ActionUser;
SQLCommand.Parameters.Add(SqlParamCycleCode);

SqlParamCycleCode := SqlParamCycleCode.SqlParameter();
SqlParamCycleCode.ParameterName := ‘@P9’;
SqlParamCycleCode.DbType := SQLDbType.String;
SqlParamCycleCode.Direction := SqlParamCycleCode.Direction.Input;
SqlParamCycleCode.Value:= OrderNo;
SQLCommand.Parameters.Add(SqlParamCycleCode);

SqlParamCycleCode := SqlParamCycleCode.SqlParameter();
SqlParamCycleCode.ParameterName := ‘@P10’;
SqlParamCycleCode.DbType := SQLDbType.String;
SqlParamCycleCode.Direction := SqlParamCycleCode.Direction.Input;
SqlParamCycleCode.Value:= Custno;
SQLCommand.Parameters.Add(SqlParamCycleCode);

SqlParamCycleCode := SqlParamCycleCode.SqlParameter();
SqlParamCycleCode.ParameterName := ‘@P11’;
SqlParamCycleCode.DbType := SQLDbType.String;
SqlParamCycleCode.Direction := SqlParamCycleCode.Direction.Input;
SqlParamCycleCode.Value:= ”;
SQLCommand.Parameters.Add(SqlParamCycleCode);

SqlParamCycleCode := SqlParamCycleCode.SqlParameter();
SqlParamCycleCode.ParameterName := ‘@P12’;
SqlParamCycleCode.DbType := SQLDbType.String;
SqlParamCycleCode.Direction := SqlParamCycleCode.Direction.Input;
SqlParamCycleCode.Value:= ”;
SQLCommand.Parameters.Add(SqlParamCycleCode);

SqlParamCycleCode := SqlParamCycleCode.SqlParameter();
SqlParamCycleCode.ParameterName := ‘@P13’;
SqlParamCycleCode.DbType := SQLDbType.String;
SqlParamCycleCode.Direction := SqlParamCycleCode.Direction.Input;
SqlParamCycleCode.Value:= ”;
SQLCommand.Parameters.Add(SqlParamCycleCode);
SQLCommand.ExecuteNonQuery;

SQLConnection.Close;
CLEAR(SQLCommand);
CLEAR(SQLConnection);
SQLConnection – System.Data.SqlClient.SqlConnection.’System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

SQLCommand – System.Data.SqlClient.SqlCommand.’System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

SqlParamCycleCode – System.Data.SqlClient.SqlParameter.’System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

SQLDbType – System.Data.DbType.’System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′