Guest_imported
New member
- Jan 1, 1970
- 0
hi
i am trying to make the DSn through the code. here is my code---
#If Win32 Then
Dim intRet As Long
#Else
Dim intRet As Integer
#End If
Dim strDriver As String
Dim strAttributes As String
Dim sourceFile As String
Dim destinationFile As String
Dim res
Dim cn As New ADODB.Connection
Dim rst As New ADODB.Recordset
sourceFile = App.Path & "\salesconnect.mdb"
destinationFile = App.Path & "\salesconnect" & CompCode & ".mdb"
res = CopyFile(sourceFile, destinationFile, False)
'DBEngine.CompactDatabase sourceFile, destinationFile
strDriver = "Microsoft Access Driver (*.mdb)"
strAttributes = "SERVER=\\vishal\c\mydocu~1\pjtDsnComp" & Chr$(0)
strAttributes = strAttributes & "DESCRIPTION=Temp DSN" & Chr$(0)
strAttributes = strAttributes & "DSN=" & "salesconnect" & CompCode & Chr$(0)
strAttributes = strAttributes & "DATABASE=c:\mydocu~1\pjtDsnComp\salesConnect.mdb" '" & CompCode & ".mdb" & Chr$(0) '& App.Path & "salesconnect" & CompCode & Chr$(0)
strAttributes = strAttributes & "UID=sa" & Chr$(0)
strAttributes = strAttributes & "PWD=" & Chr$(0)
intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_SYS_DSN, strDriver, strAttributes)
cn.Open "dsn = salesconnectC011"
rst.Open "settings", cn, adOpenKeyset, adLockOptimistic, adCmdTable
MsgBox rst(0)
If intRet Then
createDsn = True
Else
createDsn = False
End If
where SQLConfigDatasource is the function of odbccp32.dll
my problem is that the DSn is being made but it is blank i.e no database is accepted in the DSn
need urgent Help!!!
thanks
regards
Vishal
i am trying to make the DSn through the code. here is my code---
#If Win32 Then
Dim intRet As Long
#Else
Dim intRet As Integer
#End If
Dim strDriver As String
Dim strAttributes As String
Dim sourceFile As String
Dim destinationFile As String
Dim res
Dim cn As New ADODB.Connection
Dim rst As New ADODB.Recordset
sourceFile = App.Path & "\salesconnect.mdb"
destinationFile = App.Path & "\salesconnect" & CompCode & ".mdb"
res = CopyFile(sourceFile, destinationFile, False)
'DBEngine.CompactDatabase sourceFile, destinationFile
strDriver = "Microsoft Access Driver (*.mdb)"
strAttributes = "SERVER=\\vishal\c\mydocu~1\pjtDsnComp" & Chr$(0)
strAttributes = strAttributes & "DESCRIPTION=Temp DSN" & Chr$(0)
strAttributes = strAttributes & "DSN=" & "salesconnect" & CompCode & Chr$(0)
strAttributes = strAttributes & "DATABASE=c:\mydocu~1\pjtDsnComp\salesConnect.mdb" '" & CompCode & ".mdb" & Chr$(0) '& App.Path & "salesconnect" & CompCode & Chr$(0)
strAttributes = strAttributes & "UID=sa" & Chr$(0)
strAttributes = strAttributes & "PWD=" & Chr$(0)
intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_SYS_DSN, strDriver, strAttributes)
cn.Open "dsn = salesconnectC011"
rst.Open "settings", cn, adOpenKeyset, adLockOptimistic, adCmdTable
MsgBox rst(0)
If intRet Then
createDsn = True
Else
createDsn = False
End If
where SQLConfigDatasource is the function of odbccp32.dll
my problem is that the DSn is being made but it is blank i.e no database is accepted in the DSn
need urgent Help!!!
thanks
regards
Vishal