CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2002
    Posts
    756

    ODBC COnfiguration issue

    Hi,
    I am trying to call SQLConfigDataSource() in my program, but apparently I receive the following:

    The setup routines for the D ODBC driver could not be found. Please reinstall the driver.
    This is the code:

    Code:
            wcscpy( buf, L"Driver = " );
            wcscat( buf, driverName );
            ret = sqlConfigDataSource( handle, ODBC_ADD_DSN, const_cast<SQLWCHAR *>( driverName ), buf );
            if( ret != SQL_SUCCESS )
            {
                result = false;
                while( ( ret = sqlGetDiag( SQL_HANDLE_ENV, env, i, sqlState, &nativeError, errMsg, sizeof( errMsg ), &cbErrorMsg ) ) == SQL_SUCCESS )
                {
                    errorMsg.push_back( errMsg );
                    i++;
                }
            }
    Looking under the debugger, the value of 'ret' is 0, which SQL_SUCCESS. The value of 'driverName' is "Driver da Microsoft para arquivos texto (*.txt)".

    The window handle passed is correct.

    Trying to execute ODBC Administrator program from the Control Panel for this driver correctly produces the setup dialog.

    Is there a reason why I get the "D" as the driver name, and the function 'fails'?

    This is on Windows 8.1 with MSVC 2010.

    Thank you.

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: ODBC COnfiguration issue

    Not sure what sqlConfigDataSource may be, but

    Code:
    // C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\odbcinst.h
    
    BOOL INSTAPI SQLConfigDataSource     (HWND       hwndParent,
                                          WORD       fRequest,
                                          LPCSTR     lpszDriver,
                                          LPCSTR     lpszAttributes);
    The function accepts ANSI string for lpszDriver. As long as you pass L"Driver = " no surprise it appears to be just D in the call.
    Best regards,
    Igor

  3. #3
    Join Date
    Aug 2002
    Posts
    756

    Re: ODBC COnfiguration issue

    Igor,
    I'm passing (SQLWCHAR *) to the function.

    So let me try with LPCSTR...

    Thank you.

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