mibuso.com

Microsoft Business Solutions online community
It is currently Sat May 25, 2013 9:48 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: [Solved] Navision and SQL ADO Connection
PostPosted: Thu Mar 22, 2012 2:09 pm 
Offline

Joined: Thu Mar 22, 2012 1:37 pm
Posts: 10
Location: Delhi
Country: India (in)
Dear All Developer,

If you are integrating Navision and Sql server then follow the below instructions:-

1) There should not be other client's version installed on the system. Otherwise Navision Client will restart again and again.
2) user the below automation variables in

Name DataType Subtype Length
ADO_Connection Automation 'Microsoft ActiveX Data Objects 2.8 Library'.Connection
ADO_RecSet Automation 'Microsoft ActiveX Data Objects 2.8 Library'.Recordset
ADOStream Automation 'Microsoft ActiveX Data Objects 2.8 Library'.Stream
ADOCommand Automation 'Microsoft ActiveX Data Objects 2.8 Library'.Command

3) After this use the below code on Puch button or the suitable trigger wherever its required:----
// Create a connection string
ConnectionString := 'Driver={SQL Server};PROVIDER=SQLOLEDB;SERVER=SystemName;DATABASE=SQLDataBaseName;UID=UserID;PWD=Password';
// After This
BEGIN
IF ISCLEAR(ADO_Connection) THEN
CREATE(ADO_Connection);
IF ISCLEAR(ADO_RecSet) THEN
CREATE(ADO_RecSet);
IF ISCLEAR(ADOStream) THEN BEGIN
IF NOT CREATE(ADOStream) THEN BEGIN
ERROR('Cannot create ADO Stream automation variable.');
END;
END;
ADO_Connection.Open(ConnectionString);
MESSAGE('Conneciton Created');
END;

//Write the query to fetch Data

ADO_RecSet.Open('Select name,Convert(Varhcasr,ISNULL(salary,0)) from master',ADO_Connection);

//Note i have tried most what i did not get any way to insert decimal or integer values to insert in Navision from sql. So i make all the fields code of the table and insert the data in Navision.
// To convert integer or decimal data in code i use Covert() function.

Note- If value of int or decimal is blank then it show a problem such type like variable does not supported by Database.
So use IsNull() function in query.


IF (ADO_RecSet.BOF) AND (ADO_RecSet.EOF) THEN
MESSAGE('Product Records Not Found')
ELSE BEGIN
ADO_RecSet.MoveFirst;
MESSAGE('Found First');
END;

WHILE NOT ADO_RecSet.EOF DO BEGIN
LocationNew.INIT;
LocationNew.Code:=(ADO_RecSet.Fields.Item(0).Value);
LocationNew.Salary:=ADO_RecSet.Fields.Item(1).Value;

LocationNew.INSERT;
ADO_RecSet.MoveNext();
END;

ADO_Connection.Close;
MESSAGE(Text50001);


This is complete code for integration.

Thanks and Regards
Pradeep Kumar
pradeepbhardwaj478@gmail.com
pradeepkmr478@gmail.com
Mindshell Infotech Pvt. Ltd. Delhi (India)

_________________
Regards
Pradeep Bhardwaj


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: