User og password problem ved oprettelse af ODBC
Jeg bruger følgende kode til at oprette en ODBC.Hvis jeg opretter uden UID og PWD fungerer det fint, men ikke når jeg gerne vil have de to attributter med.
Nogle gode forslag til hvad der går galt?
Private Const ODBC_CONFIG_SYS_DSN = 4
Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" _
(ByVal hwndParent As Long, ByVal fRequest As Long, _
ByVal lpszDriver As String, ByVal lpszAttributes As String) _
As Long
Private Sub Command1_Click()
Dim intret As Long
Dim strDriver As String
Dim strAttributes As String
strDriver = "SQL Server"
strAttributes = "SERVER=MinServer" & Chr$(0)
strAttributes = strAttributes & "DESCRIPTION=NySystemDsn" & Chr$(0)
strAttributes = strAttributes & "DSN=Ny" & Chr$(0)
strAttributes = strAttributes & "DATABASE=MinDB" & Chr$(0)
strAttributes = strAttributes & "UID=User" & Chr(0)
strAttributes = strAttributes & "PWD=Kodeord" & Chr(0)
intret = SQLConfigDataSource(vbAPINull, ODBC_CONFIG_SYS_DSN, strDriver, strAttributes)
If intret Then
MsgBox "DSN Created"
Else
MsgBox "Create Failed"
End If
End Sub
