Create a Nodbc DSN with VB.Net

HaroldVanAarsen
Member Posts: 8
With VB.Net I can create a DSN for for example Access or MS SQL.
Now i trie it for a DSN for Navision with the Nodbc driver.
I created the code as shown here:
and it only returns the form from wich I can define a DSN, without any of the atributes set above.
What is going wrong ?
Can anybody tell me ?
With kind regards,
Harold van Aarsen
Now i trie it for a DSN for Navision with the Nodbc driver.
I created the code as shown here:
Private Declare Function SQLDataSources Lib "ODBC32.DLL" (ByVal henv As Integer, _ ByVal fDirection As Short, _ ByVal szDSN As String, _ ByVal cbDSNMax As Short, _ ByRef pcbDSN As Short, _ ByVal szDescription As String, _ ByVal cbDescriptionMax As Short, ByRef pcbDescription As Short) As Short Private Declare Function SQLAllocEnv Lib "ODBC32.DLL" (ByRef env As Integer) As Short Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" (ByVal hwndParent As Integer, _ ByVal ByValfRequest As Integer, _ ByVal lpszDriver As String, _ ByVal lpszAttributes As String) As Integer Const SQL_SUCCESS As Integer = 0 Const SQL_FETCH_NEXT As Integer = 1 Private Const ODBC_ADD_DSN As Short = 1 ' Add user data source Private Const ODBC_CONFIG_DSN As Short = 2 ' Configure (edit) data source Private Const ODBC_REMOVE_DSN As Short = 3 ' Remove data source Private Const ODBC_ADD_SYS_DSN As Short = 4 'Add system data source Private Const vbAPINull As Integer = 0 ' NULL Pointer Public Sub CreateSystemDSN() Dim ReturnValue As Integer Dim Driver As String Dim Attributes As String Driver = "Microsoft Navision Driver" Attributes = "DESCRIPTION=TestHarold" & Chr(0) Attributes = Attributes & "DSN=Test_Harold" & Chr(0) Attributes = Attributes & "PWD = hva1910" & Chr(0) Attributes = Attributes & "EnableBlob = yes" & Chr(0) Attributes = Attributes & "Language = Auto (Windows Language)" & Chr(0) Attributes = Attributes & "Driver = C:\\Program Files\\Common Files\\Navision\\NODBC\\nodbc.dll" & Chr(0) Attributes = Attributes & "QryPlan = 0" & Chr(0) Attributes = Attributes & "RegionalDecSymbol = no" & Chr(0) Attributes = Attributes & "NoJoinOpt = 0" & Chr(0) Attributes = Attributes & "ReadOnly = no" & Chr(0) Attributes = Attributes & "ServerName = mbs40live" & Chr(0) Attributes = Attributes & "MaxColSupport = " & Chr(0) Attributes = Attributes & "ViewFileDirectory = " & Chr(0) Attributes = Attributes & "Server = yes" & Chr(0) Attributes = Attributes & "NoIndexes = 0" & Chr(0) Attributes = Attributes & "ClosingDate = no" & Chr(0) Attributes = Attributes & "NetType = tcp" & Chr(0) Attributes = Attributes & "CompanyName = Vogelzang Dakelementen b.v." & Chr(0) Attributes = Attributes & "FiltSpy = 0" & Chr(0) Attributes = Attributes & "WindowsLogin = no" & Chr(0) Attributes = Attributes & "CommitCache = yes" & Chr(0) Attributes = Attributes & "UserID = harold" & Chr(0) Attributes = Attributes & "DatabaseName = " & Chr(0) Attributes = Attributes & "ProgramFolder = C:\\Program Files\\Common Files\\Navision\\NODBC" & Chr(0) Attributes = Attributes & "Identifiers = 0" & Chr(0) Attributes = Attributes & "DrmSpy = 0" & Chr(0) Attributes = Attributes & "OptionFieldType = Text" & Chr(0) Attributes = Attributes & "CODEPAGE = " & Chr(0) Attributes = Attributes & "DBMSCache = 8000" & Chr(0) Attributes = Attributes & "NoFiltOpt = 0" & Chr(0) ReturnValue = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, "Microsoft Navision Driver", Attributes) If ReturnValue <> 0 Then MsgBox("DSN Created") Else MsgBox("Create Failed") End If End Sub
and it only returns the form from wich I can define a DSN, without any of the atributes set above.
What is going wrong ?
Can anybody tell me ?
With kind regards,
Harold van Aarsen
Harold van Aarsen
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