Results 1 to 3 of 3

Thread: ODBC creation error

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Posts
    19
    trying to add a ODBC driver in the following code using VB6 but getting DSN failed:

    Private Declare Function SQLConfigDataSource Lib "odbccp32.dll" (ByVal hwndParent As Long, ByVal fRequest As Integer, ByVal lpszDriver As String, ByVal lpszAttributes As String) As Long
    Private Const ODBC_ADD_DSN = 1 ' Add a new data source.
    Private Const ODBC_CONFIG_DSN = 2 ' Configure (edit) existing data source.
    Private Const ODBC_REMOVE_DSN = 3 ' Remove existing data source.
    Private Const ODBC_ADD_SYS_DSN = 4 ' Add data source
    Private Const ODBC_CONFIG_SYS_DSN = 5 ' Configure (edit) data source
    Private Const ODBC_REMOVE_SYS_DSN = 6 ' Remove data source
    Private Sub Command1_Click()
    On Error Resume Next
    If SQLConfigDataSource(0, ODBC_ADD_SYS_DSN, _
    "Microsoft Access Driver", _
    "DSN=" & "Test" & Chr(0) & _
    "DESCRIPTION=" & "Test" & Chr(0) & _
    "SOURCETYPE=DBC" & Chr(0) & _
    "SOURCEDB=" & "C:\Work\Op2\Database\Op2_desktop.mdb" & Chr(0) & _
    "BACKGROUNDFETCH=YES" & Chr(0) & _
    "NULL=YES" & Chr(0) & _
    "DELETED=YES" & Chr(0) & _
    "EXCLUSIVE=NO" & Chr(0) & Chr(0)) Then
    MsgBox "DSN Created"
    Else
    MsgBox "DSN Failed"
    End If
    End Sub

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    You have Microsoft Access Driver specified wrong.
    Change this:

    Microsoft Access Driver

    To this:

    Microsoft Access Driver {*.mdb}

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Posts
    19
    Has anyone else got any ideas as the above did not work.

    Regards
    Daryl Collins

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width