Navision <=> MySQL Interface with ADO

Hi guys, I have to develop a interface between navision 3.70 and a mySQL-database. I’ve already experiences with ADO but I have no idea how to connect ADO to mySQL, especially I don’t know the connection sting. Can anybody help? Thank you in advance!! Andreas (Cologne, Germany)

Do you want to code this WITHIN Navision or OUTSIDE Navision?

Thank you for your reply. It should be developped inside navision cause the interface has to execute standard-functions inside navision. The interface should run on a navision-application-server. Andreas

Andreas, I’ve never done this to mysql, but I’ve written reports for Clipper/Dbase before. Anyway, for MySql, I think it’s: oConn.Open “Provider=MySQLProv;” & _ “Data Source=mySQLDB;” & _ “User Id=myUsername;” & _ “Password=myPassword” Also, there are 3rd party controls to access mysql. You can check out: http://crlab.com/mysqlnet/ as an example. Good luck! -john p.s. bookmark http://www.connectionstrings.com/ for future projects!

I’ll get back to you Monday with some code that works for sure. Hope you can wait so long!

Of course I can wait. You guys are great!!

As requested… CREATE(AdoConnection); AdoConnection.Open('DSN=mySQL;SERVER=192.168.1.1;UID=root;database=PrinterList','','',0); AdoRecordset := AdoConnection.Execute('SELECT PrinterName FROM Printers',RecordsAffected,0); IF NOT AdoRecordset.EOF THEN AdoRecordset.MoveFirst; WHILE NOT AdoRecordset.EOF DO BEGIN MESSAGE(FORMAT(AdoRecordset.Fields.Item('Printer').Value)); AdoRecordset.MoveNext; END; RecordsAffected = Integer AdoConnection = ‘Microsoft ActiveX Data Objects 2.7 Library’.Connection AdoRecordset = ‘Microsoft ActiveX Data Objects 2.7 Library’.Recordset Have fun…

Forgot to mention: It works using both SELECT, INSERT & UPDATE. Depending on ADO version RecordsAffected might return (-1) using SELECT even if records ARE returned. Just to let you know [:)].

Hi, I try to implement your solution in a report because I do not have a full developpement licence. When I do the declaration in globals of AdoConnection, it runs fine but the AdoRecordset fails at run time: the variable ADRORECORDSET::WILLCHANGERECORD is defined more than once. I use win XP, MDAC 2.8, Navision 3.70.

When you created the global variable ‘AdoRecordset’, did you set the ‘WithEvents’ property to ‘Yes’? When you do this, the C/SIDE environment automatically creates triggers for the various events that an automation object raises. C/SIDE uses a naming convention for these triggers in the following pattern: :: However, C/SIDE trigger names cannot be more than 30 characters long, so the created trigger names are truncated when they are too long. This sometimes leads to the duplicate name problem. Solution(s): a) remove the ‘WithEvents’ property, if you don’t need the event triggers, or b) choose a shorter so that the resultant trigger names aren’t truncated.

Just want to thank Preben for this excellent piece of code. Within an hour I had the connection up and running [;)] I am using the following connection string: ‘DSN=mySQL;Server=192.168.0.101;Port=3306;Option=131072;Stmt=;Database=databasename;Uid=userid;Pwd=password;’ And this MySQL ODBC driver: http://dev.mysql.com/downloads/connector/odbc/3.51.html Saludos Nils

You’re welcome…