Private Shared Sub CreateSystemDSN() 'create dsn programmatically Dim ReturnValue As Integer Dim Driver As String Dim Attributes As String 'Set the driver to SQL Server because it is most common. Driver = "SQL Server" 'Set the attributes delimited by null. 'See driver documentation for a complete 'list of supported attributes. Attributes = "SERVER=" & dbServer & Chr(0) Attributes = Attributes & "DESCRIPTION=" & dbName & Chr(0) Attributes = Attributes & "DSN=" & dbName & Chr(0) Attributes = Attributes & "DATABASE=" & dbName & Chr(0) '---> error part Attributes = Attributes & "TRUSTED_CONNECTION=NO" & Chr(0) Attributes = Attributes & "UID=" & dbUser & Chr(0) Attributes = Attributes & "PWD=" & dbPassword & Chr(0) '---> end of error part 'To show dialog, use Form1.Hwnd instead of vbAPINull. ReturnValue = SQLConfigDataSource(vbAPINull, ODBC_ADD_SYS_DSN, Driver, Attributes) If ReturnValue <> 0 Then MsgBox("DSN Created") Else MsgBox("Please contact administrator. ODBC Connection failed.") End If End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)