|
I try to create sys dsn from my C++ application
but i have always the same error:
The installation routines ODBC Microsoft Access Driver (*. Mdb) are not found. Please reinstall the driver.
I have Office 2007 installed but always error
For example this a VB test which return failed:
Public Class Form1
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
Private Const ODBC_ADD_SYS_DSN As Short = 4
Private Const vbAPINull As Integer = 0
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
CreateSystemDSN()
End Sub
Public Sub CreateSystemDSN()
Dim ReturnValue As Integer
Dim Driver As String
Dim Attributes As String
Driver = "Microsoft Access Driver (*.mdb)"
Attributes = "SERVER=SomeServer" & Chr(0)
Attributes = Attributes & "DESCRIPTION=New DSN" & Chr(0)
Attributes = Attributes & "DSN=DSN_TEMP" & Chr(0)
Attributes = Attributes & "DATABASE=pubs" & Chr(0)
ReturnValue = SQLConfigDataSource(vbAPINull, ODBC_ADD_SYS_DSN, Driver, Attributes)
If ReturnValue <> 0 Then
MsgBox("DSN Created")
Else
MsgBox("Create Failed")
End If
End Sub
End Class
Thank you.
|
|
|
|