ODBC data base with the VC++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gnanapoongothai
    New Member
    • Jun 2007
    • 62

    ODBC data base with the VC++

    i Am programming to establish connectivity to Mysql server and when setting the attribute to the environment handle the error is invalid valueptr to the attribute.
    And also the connection handle is not allocated in version 3.I need help from u ppl.

    and also say the sequence , i am totall confused with MSDN.
    and here is my code
    [code=cpp]
    ret = SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE ,&envr);


    if(ret == SQL_SUCCESS || ret == SQL_SUCCESS_WIT H_INFO)
    {
    ret = SQLAllocHandle( SQL_HANDLE_DBC, envr,&hdbc);
    }

    //if(ret == SQL_SUCCESS || ret == SQL_SUCCESS_WIT H_INFO)
    {
    ret = SQLSetEnvAttr(e nvr,SQL_ATTR_OD BC_VERSION,prt, 20);
    }
    ret = SQLGetDiagRec(S QL_HANDLE_ENV,e nvr,1,sqlstate, &nativeerror,ms g,100,&msglen);

    //if(ret == SQL_SUCCESS || ret == SQL_SUCCESS_WIT H_INFO)
    {
    ret = SQLSetConnectAt tr(&hdbc,SQL_AT TR_LOGIN_TIMEOU T,0,0);
    }
    ret = SQLGetDiagRec(S QL_HANDLE_DBC,& hdbc,1,sqlstate ,&nativeerror,m sg,100,&msglen) ;


    //if(ret == SQL_SUCCESS || ret == SQL_SUCCESS_WIT H_INFO)
    {
    ret = SQLConnect(hdbc ,(SQLCHAR*)"pmu ",SQL_NTS,(SQLC HAR*)"root",SQL _NTS,(SQLCHAR*) "root",SQL_NTS) ;
    }
    ret = SQLGetDiagRec(S QL_HANDLE_DBC,& hdbc,1,sqlstate ,&nativeerror,m sg,100,&msglen) ;



    if(ret == SQL_SUCCESS || ret == SQL_SUCCESS_WIT H_INFO)
    {
    ret = SQLAllocHandle( SQL_HANDLE_STMT ,hdbc,&hline);
    }
    if(ret == SQL_SUCCESS || ret == SQL_SUCCESS_WIT H_INFO)
    {
    ret = SQLSetStmtAttr( hline,SQL_ATTR_ ROW_BIND_TYPE,s izeof(Ia12),0);
    ret = SQLSetStmtAttr( hline,SQL_ATTR_ ROW_ARRAY_SIZE, 10,0);[/code]
    Last edited by sicarie; Nov 7 '07, 01:39 PM. Reason: Code tags
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    gnanapoongothai-

    You are a member of this community, and as such, are expected to follow the Posting Guidelines in such things as using code tags. Thanks.

    Comment

    Working...