Click here to Skip to main content
15,913,854 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRadio Button groups Pin
act_x16-Jul-03 8:49
act_x16-Jul-03 8:49 
GeneralRe: Radio Button groups Pin
John R. Shaw16-Jul-03 9:17
John R. Shaw16-Jul-03 9:17 
GeneralRe: Radio Button groups Pin
act_x16-Jul-03 10:43
act_x16-Jul-03 10:43 
GeneralRe: Radio Button groups Pin
John R. Shaw16-Jul-03 11:16
John R. Shaw16-Jul-03 11:16 
GeneralRe: SHBrowseForFolder works only one time when connecting to SQL server in between when using a manifest file Pin
Jens Doose16-Jul-03 8:18
Jens Doose16-Jul-03 8:18 
GeneralRe: SHBrowseForFolder works only one time when connecting to SQL server in between when using a manifest file Pin
David Crow16-Jul-03 9:42
David Crow16-Jul-03 9:42 
GeneralRe: SHBrowseForFolder works only one time when connecting to SQL server in between when using a manifest file Pin
Jens Doose16-Jul-03 20:21
Jens Doose16-Jul-03 20:21 
GeneralRe: SHBrowseForFolder works only one time when connecting to SQL server in between when using a manifest file Pin
David Crow17-Jul-03 5:49
David Crow17-Jul-03 5:49 
Jens Doose wrote:
bi is used again in the second call to SHBrowseForFolder.

Right, but's it's still not being used. Wink | ;) The code pieces are disparate. The usage of 'bi' and the success/failure of the calls to SHBrowseForFolder() have nothing to do with the SQL-related stuff.

It's considered good practice to check the return values from all function calls. Something like:

void Go( void )
{
    BROWSEINFO  bi = {0};
    SQLRETURN   sqlRet
    SQLHENV     env = NULL;
    SQLHDBC     conn = NULL;
    SWORD       len = 0,
                nMessageLen = 0;
    SQLCHAR     szOut[2048] = {0},
                sqlConn[1024] = "DRIVER={SQL Server};SERVER=(local)";
    UCHAR       szMessage[ SQL_MAX_MESSAGE_LENGTH ] = {0},
                szErrorState[ SQL_SQLSTATE_SIZE + 1 ] = {0};
    SDWORD      dwNativeErrorCode = 0;

    
    bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS;

    SHBrowseForFolder( &bi );

    sqlRet = SQLAllocEnv(&env);
    if (SQL_SUCCESS == sqlRet)
    {
        sqlRet = SQLAllocConnect(env, &conn);
        if (SQL_SUCCESS == sqlRet)
        {
            sqlRet = SQLDriverConnect(conn, NULL, sqlConn, SQL_NTS, szOut, sizeof(szOut), &len, SQL_DRIVER_COMPLETE_REQUIRED);
            if (SQL_SUCCESS != sqlRet && SQL_SUCCESS_WITH_INFO != sqlRet)
            {
                sqlRet = SQLError(env, conn, SQL_NULL_HSTMT, szErrorState, &dwNativeErrorCode, szMessage, SQL_MAX_MESSAGE_LENGTH - 1, &nMessageLen);

                ::MessageBox(NULL, (CHAR *) szMessage, (CHAR *) szErrorState, MB_OK);
            }

            sqlRet = SQLDisconnect(conn);

            sqlRet = SQLFreeHandle(SQL_HANDLE_DBC, conn);
        }

        sqlRet = SQLFreeHandle( SQL_HANDLE_ENV, env );
    }

    ZeroMemory(&bi, sizeof(bi));
    bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS;
    SHBrowseForFolder(&bi);
}

Jens Doose wrote:
This happens only with the MS SQL Server ODBC driver.
If another driver is used (MS Text driver, Sybase Anywhere)
it works fine.


Or it's just being masked such that it appears fine.
GeneralRe: SHBrowseForFolder works only one time when connecting to SQL server in between when using a manifest file Pin
Jens Doose17-Jul-03 19:34
Jens Doose17-Jul-03 19:34 
GeneralRe: SHBrowseForFolder works only one time when connecting to SQL server in between when using a manifest file Pin
David Crow18-Jul-03 5:54
David Crow18-Jul-03 5:54 
GeneralWM_CONTEXTMENU Pin
pranavamhari16-Jul-03 7:34
pranavamhari16-Jul-03 7:34 
QuestionMFC - How to print ? Pin
Exim16-Jul-03 6:55
Exim16-Jul-03 6:55 
GeneralHeapValidate question Pin
Anonymous16-Jul-03 6:27
Anonymous16-Jul-03 6:27 
GeneralRe: HeapValidate question Pin
Mike Dimmick16-Jul-03 6:48
Mike Dimmick16-Jul-03 6:48 
GeneralRe: HeapValidate question Pin
Anonymous16-Jul-03 7:09
Anonymous16-Jul-03 7:09 
GeneralRe: HeapValidate question Pin
Peter Weyzen16-Jul-03 7:52
Peter Weyzen16-Jul-03 7:52 
GeneralRe: HeapValidate question Pin
Mike Dimmick16-Jul-03 22:28
Mike Dimmick16-Jul-03 22:28 
QuestionGetting the same value everytime?? Pin
johnstonsk16-Jul-03 6:01
johnstonsk16-Jul-03 6:01 
AnswerRe: Getting the same value everytime?? Pin
David Crow16-Jul-03 7:02
David Crow16-Jul-03 7:02 
AnswerRe: Getting the same value everytime?? Pin
Peter Weyzen16-Jul-03 7:58
Peter Weyzen16-Jul-03 7:58 
AnswerRe: Getting the same value everytime?? Pin
Ryan Binns16-Jul-03 17:33
Ryan Binns16-Jul-03 17:33 
GeneralEDID data, display driver Pin
oliver.hu16-Jul-03 5:19
oliver.hu16-Jul-03 5:19 
GeneralTemplates and functions Pin
Bernhard16-Jul-03 4:59
Bernhard16-Jul-03 4:59 
GeneralRe: Templates and functions Pin
Ryan Binns16-Jul-03 5:06
Ryan Binns16-Jul-03 5:06 
GeneralRe: Templates and functions Pin
Andrew Walker17-Jul-03 3:03
Andrew Walker17-Jul-03 3:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.