CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2002
    Location
    Greece , athens
    Posts
    2

    Question Help on installing DSN connection to ODBC by installer

    I have an application which uses an mdb file , and im trying to figure out how to install this in ODBC thru the installer

    The installer is InstallAnywhere 4.5.2.

    I think that i need a C++ program to make ena api call to ODBC API is that right?

    And if so , is there any example?

    Thanks~!!

  2. #2
    Join Date
    May 2002
    Location
    Colombo,Sri Lanka
    Posts
    1,110
    I haven't use InstallAnywhere But I think from that u can run a other exe.
    Following code is from vb to create a dsn.


    ByVal sDriver As String, _
    ByVal sDBFile As String, _
    ByVal eAction As ACTION _
    )

    Dim sAttributes As String
    Dim sDBQ As String
    Dim sRegValue As String
    Dim lRetVal As Long
    Dim hKey As Long
    Dim lValueType As Long
    Dim sMessage As String

    If RegOpenKeyEx(HKEY_CURRENT_USER, _
    "Software\ODBC\ODBC.INI\" & sDSN, _
    0, _
    KEY_ALL_ACCESS, hKey _
    ) = 0 Then

    sRegValue = String(1024, 0)

    If RegQueryValueEx(hKey, _
    "DBQ", _
    0, _
    lValueType, _
    sRegValue, _
    Len(sRegValue) _
    ) = 0 Then

    If lValueType = REG_SZ Then
    sDBQ = Left(sRegValue, InStr(sRegValue, vbNullChar) - 1)
    End If
    End If

    RegCloseKey hKey
    End If

    If (sDBQ = "" And (eAction = ODBC_ADD_DSN Or eAction = ODBC_ADD_SYS_DSN)) _
    Or _
    (sDBQ <> "" And (eAction = ODBC_REMOVE_DSN Or eAction = ODBC_CONFIGURE_DSN)) Then

    If Len(Dir(sDBFile)) = 0 Then
    MsgBox "Database file doesn't exist!", vbOKOnly + vbCritical, "Cannot Continue"
    Else
    sAttributes = "DSN=" & sDSN & vbNullChar & "DBQ=" & sDBFile & vbNullChar
    lRetVal = SQLConfigDataSource(0&, eAction, sDriver, sAttributes)
    MsgBox "Done!"
    End If
    Else
    If eAction = ODBC_ADD_DSN Or _
    eAction = ODBC_ADD_SYS_DSN Then

    sMessage = " already exists!"
    Else
    sMessage = " doesn't exist!"
    End If

    MsgBox "DSN: " & txtDsnName.Text & sMessage
    End If

    End Sub

  3. #3
    Join Date
    Jul 2002
    Location
    Greece , athens
    Posts
    2

    Thank you!

    Thank you for your reply!!!

    I did found an installer that installs Dsn , called WiseInstaller

    i ll work both!

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

Featured