I would like to get data from Navision database to Excel (through C/ODBC, ADO & VBA). When my code tries to open an ODBC connection with Navision database, an error occurs: “ISAM error”. I can read this message in ADODB.Error.description field. But this Excel (and Access, and such a tool called “Query Tool ODBC”) is able to import data from this ODBC data source with no problems. My code looks like that: … Dim gConnection As New ADODB.Connection Dim gError as New ADODB.Error … ’ every necessary Navision parameter is defined in My_DSN gConnection.ConnectionString=“DSN=My_DSN” on error goto ErrorHandler gConnection.Open … exit sub ErrorHandler: MsgBox gError.description … I’m using MS Office 2000 (SP1) with ADO 2.7 & Navision 3.10 on MS Windows XP (SP1). 1. What is wrong with my code? 2. How I can get a little more precise error message (error number?, error description?). 3. Have You some sample of VBA / C++ / Java code using ADO & C/ODBC & Navision database? Thank You in advance Jacob
I think you have to start your connection string with ODBC; like gConnection.ConnectionString=“ODBC;DSN=<My_DSN>” But i don’t check it, i prefer specify all parameters than use a DSN see on this forum http://www.mbsonline.org/forum/topic.asp?TOPIC_ID=9194 I hope this will help you Best regards Patrick
Here is some code I used to read data from Navision: Sub GetODBCData() Dim myConnection Set myConnection = CreateObject(“ADODB.Connection”) myConnection.Open “Lopro” //a System DSN with this name has to exist If Not myConnection.State = 1 Then MsgBox “Verbindung fehlgeschlagen.” //connection failed GoTo ende End If Auswahl.Feldliste.Clear Set adoRecordset = CreateObject(“ADODB.Recordset”) adoRecordset.Open “Abfragefelder”, myConnection Do Until adoRecordset.EOF Auswahl.Feldliste.AddItem Auswahl.Feldliste.List(Auswahl.Feldliste.ListCount - 1, 0) = adoRecordset!Feldname Auswahl.Feldliste.List(Auswahl.Feldliste.ListCount - 1, 1) = adoRecordset!Beschreibung adoRecordset.movenext Loop adoRecordset.Close ende: myConnection.Close End Sub