Sub createDSN() Const ODBC_ADD_SYS_DSN = 4 ' Add data source Dim dbpath As String = "C:\Jenit\Data\001.accdb" Dim ret As Integer, Driver As String, Attributes As String Driver = "Microsoft Access Driver (*.MDB,*.accdb)" & Chr(0) Attributes = "DSN=" & "Hello" & Chr(0) Attributes = Attributes & "Uid=Admin" & Chr(0) & "pwd=pwd" & Chr(0) Attributes = Attributes & "DBQ=" & dbpath & Chr(0) & Chr(0) ret = SQLConfigDataSource(0&, ODBC_ADD_SYS_DSN, Driver, Attributes) 'Error Here 'ret is equal to 1 on success and 0 if there is an error If ret <> 1 Then MsgBox("DSN Creation Failed") Else MsgBox("Successful") End If End Sub 'Main
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)