How to Execute SQL instructions from Navision

HanenHanen Member Posts: 281
edited 2009-10-17 in SQL General

Hello, I have some instructions SQL Server on my Unit Code, but I don't know how to use these statement, any one can help me please :(

IF ISCLEAR(lADOConnection) THEN CREATE(lADOConnection);
lADOConnection.ConnectionString:=ChaineConnection;
lADOConnection.Open;
//*************************************************************** Execute SP *************************
Customer1:= Code1;
Customer2:=code2;

lvarActiveConnection := lADOConnection;
IF ISCLEAR(lADOCommand) THEN CREATE(lADOCommand);
lADOCommand.ActiveConnection := lvarActiveConnection;
lADOCommand.CommandText := 'TEST';
lADOCommand.CommandType := 4; 
lADOCommand.CommandTimeout := 0;    

lADOParameter:=lADOCommand.CreateParameter('@CustomerNo1', 200, 1, 20,Customer1);
lADOCommand.Parameters.Append(lADOParameter);

lADOParameter:=lADOCommand.CreateParameter('@CustomerNo2', 200, 1, 20,Customer2);
lADOCommand.Parameters.Append(lADOParameter);

// Open recordset
// OSql = SQL Statement.
OSQL :=
'
 EXEC sp_makewebtask 
@outputfile = 'd:\testing_Hanen.xls', 	
@query = [exec PSBI013],	
@colheaders =1, 	
@FixedFont=0,	
@lastupdated=1,    
@resultstitle='Testing details'

';

// Create object automation
IF ISCLEAR(NavRec) THEN
CREATE(NavRec);
NavRec:=lADOConnection.Execute(OSql,OReturnNbRecord);
// First record
NavRec.MoveFirst;
REPEAT
// Move to next record.
NavRec.MoveNext;

//Until end of file.
UNTIL NavRec.EOF;

//Close the connection.
lADOConnection.Close;
// Libération des objets automation.
CLEAR(NavRec);
CLEAR(lADOConnection);



Thanks for your help!!!!!
Regards

Hanen TALBI

Comments

Sign In or Register to comment.