Call Stored Procedure from Dynamics Navision (Automation Variable)

 

IF ISCLEAR(ADOConnection) THEN
CREATE(ADOConnection,FALSE,TRUE);

ADOConnection.ConnectionString:=
‘Driver={SQL Server};’
+ ‘Server=’+’SERVER NAME’+’;’
+ ‘Database=’+’DATABASE NAME’+’;’
+ ‘Uid=’+’SQLUID’+’;’
+ ‘Pwd=’+’SQLPWD’+’;’;

ADOConnection.Open;

IF ISCLEAR(ADOCommand) THEN
CREATE(ADOCommand,FALSE,TRUE);

VarActiveConnection := ADOConnection;
ADOCommand.ActiveConnection := VarActiveConnection;
ADOCommand.CommandText := ‘ProcedureName’;
ADOCommand.CommandType := 4;
ADOCommand.CommandTimeout := 0;

ADOParameter:=ADOCommand.CreateParameter(‘@EventCode’,3,1,3,eventcode);
ADOCommand.Parameters.Append(ADOParameter);

ADOParameter:=ADOCommand.CreateParameter(‘@P1’,3,1,3,0);
ADOCommand.Parameters.Append(ADOParameter);

ADOParameter:=ADOCommand.CreateParameter(‘@P2’,3,1,3,0);
ADOCommand.Parameters.Append(ADOParameter);

ADOParameter:=ADOCommand.CreateParameter(‘@P3’,3,1,3,0);
ADOCommand.Parameters.Append(ADOParameter);

ADOParameter:=ADOCommand.CreateParameter(‘@P4’,3,1,3,WebUserId);
ADOCommand.Parameters.Append(ADOParameter);
ADOParameter:=ADOCommand.CreateParameter(‘@P5’,3,1,3,NoOfOrder);
ADOCommand.Parameters.Append(ADOParameter);

ADOParameter:=ADOCommand.CreateParameter(‘@P6’,200,1,50,TriggerModule);
ADOCommand.Parameters.Append(ADOParameter);

ADOParameter:=ADOCommand.CreateParameter(‘@P7’,200,1,50,TriggerSource);
ADOCommand.Parameters.Append(ADOParameter);

ADOParameter:=ADOCommand.CreateParameter(‘@P8’,200,1,50,ActionUser);
ADOCommand.Parameters.Append(ADOParameter);

ADOParameter:=ADOCommand.CreateParameter(‘@p9’,200,1,50,OrderNo);
ADOCommand.Parameters.Append(ADOParameter);

ADOParameter:=ADOCommand.CreateParameter(‘@P10’,200,1,50,Custno);
ADOCommand.Parameters.Append(ADOParameter);

ADOParameter:=ADOCommand.CreateParameter(‘@P11’,200,1,100,”);
ADOCommand.Parameters.Append(ADOParameter);

ADOParameter:=ADOCommand.CreateParameter(‘@P12’,200,1,100,”);
ADOCommand.Parameters.Append(ADOParameter);

ADOParameter:=ADOCommand.CreateParameter(‘@P13’,200,1,100,”);
ADOCommand.Parameters.Append(ADOParameter);
ADOCommand.Execute;
ADOConnection.Close;
CLEAR(ADOConnection);
ADOCommand  – Automation ‘Microsoft ActiveX Data Objects 2.8 Library’.Command
ADOParameter – Automation ‘Microsoft ActiveX Data Objects 2.8 Library’.Parameter
VarActiveConnection – Variant
ADOConnection Automation –  Microsoft ActiveX Data Objects 2.8 Library’.Connection

Advertisements