Get DB connection to MS Acceess from NAV 2009 R2

Gabry
Member Posts: 48
I know how to get the connection from MS SQL Server (see code below), but not from MS Access (<file_name>.mdb). I am not able to get the string connection data from MS Access.
Do you know how to open the connection?
Do you know how to open the connection?
SQLServerName := 'PC16\SQLEXPRESS'; SQLUserID := 'AlfaViewer'; SQLPassword := 'xxx'; SQLDB := 'D2000Sql'; IF lRtc THEN BEGIN SQLConnectionString := 'Server='+SQLServerName + ';' + 'Database='+SQLDB + ';' + 'User=' + SQLUserID + ';' + 'Password=' + SQLPassword + ';' + 'Connection Timeout=20;'; SQLConnection := SQLConnection.SqlConnection(SQLConnectionString); txtStartDate := FORMAT(StartDate,8,'<Year4><Month,2><Day,2>'); txtEndDate := FORMAT(EndDate,8,'<Year4><Month,2><Day,2>'); SQLConnection.Open; SQLCommand := SQLConnection.CreateCommand(); IF SalesPoint.GET(SalesPointCode) THEN SQLCommand.CommandText := 'select * From [view_MultiTabella] ' + 'where (DataReg BETWEEN ''' + txtStartDate + ''' AND ''' + txtEndDate + ''') AND (Impianto = ''' + SalesPointCode + ''')' ELSE SQLCommand.CommandText := 'select * From [view_MultiTabella] ' + 'where (DataReg BETWEEN ''' + txtStartDate + ''' AND ''' + txtEndDate + ''')'; SQLReader := SQLCommand.ExecuteReader; END;
0
Comments
-
I replaced the SQL provider with ODBC provider as it is shown in the code below. But running it using RTC the following error occurs:
"This message id for C/AL programmers: The call to member System.Data.Odbc.OdbcConnection failed: Format of the initialization string does not conform to specialization starting at index 0."
I suppose that is a problem with connection string: do you know how to set it for MS Access?SQLConnectionString := 'C:\AF\DecryptDatabase.mdb'; ODBCConnection := ODBCConnection.OdbcConnection(SQLConnectionString); ODBCConnection.Open(); ODBCCommand := ODBCConnection.CreateCommand(); ODBCCommand.CommandText := 'select * from CarichiEff where CaricoEff_Numero = 1'; ODBCReader := ODBCCommand.ExecuteReader();
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions