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