Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2006

    Unanswered: ODBC behaviour with Windows messaging API

    My Database ODBC Driver is behaving strange with an application that uses
    windows methods
    _bstr_t getInvs;
    getInvs = "select * from temp";
    m_GetInvsCommand.CreateInstance(__uuidof(Command)) ;
    m_GetInvsCommand->ActiveConnection = m_DBHandler->mConnection ;

    SQLDriverConnect is already called in the begining of the application.These calls are done before SQLPrepare .

    Dont know why with m_GetInvsCommand->ActiveConnection = m_DBHandler->mConnection ;
    SQLDriverconnect is called again.New connection handle is also allocated...
    kind off confused
    Anyone seen this error before?

  2. #2
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    Maybe I'm confused, but someone (probably you) has to write all of the C code that uses an ODBC driver. Code doesn't materialize out of thin air just because you use the driver.

    Can you explain what you are asking more clearly?


  3. #3
    Join Date
    Apr 2006
    Hi pat ,
    Thanks for your response. I have written a small application that would be connected to a ODBC Driver OpenConnection ADO method would call SQLDriverConnect.

    Later in BOOL PrepareMPSUpdate1() function when

    m_GetInvsCommand1.CreateInstance(__uuidof(Command) );
    m_GetInvsCommand1->ActiveConnection = m_DBHandler->mConnection ;

    is called SQLDriverConnect is called again.Wondering why this kind of behaviour.This is not reproducible in oracle.
    But in my ODBC driver this is the behavior,hope this can give some idea...

    #include "stdafx.h"
    #include "windows.h"
    #include "DBHandler.h"
    #include "conio.h"
    #include <sys/timeb.h>

    typedef struct MKIPrice
    long MKINo;
    char type[4];
    char Exch[4];
    double YCP;
    double LTP;
    short Level;
    double InitalTrigValLow;
    double InitalTrigValHig;
    double IncrTrigpriceLow;
    double IncrTrigpriceHig;
    char StockGroup;
    bool MkiFlag;


    static bool gflag = false;
    typedef char TUserCode[13];
    DWORD m_dwThreadID;
    HANDLE m_hThread,m_hTimerQueue,m_hTimer;
    CDBHandler *m_DBHandler;
    CTracer *m_pTracer;

    BOOL PrepareMPSUpdate1();
    BOOL PrepareMPSUpdate();
    BOOL UpdateMPS();
    void GetNSOdbc_time_stamp(char *timedate);

    _CommandPtr m_MkiTrueCommand,m_MkiFalseCommand,m_SelectMkiComm and;
    _CommandPtr m_GetInvsCommand1,m_GetInvsCommand,m_UpdateCommand ,m_InsertCommand;
    _ParameterPtr m_PctParam;
    _ParameterPtr m_Qty,m_Qty1;
    _ParameterPtr m_MkiNum,m_MkiNum1;
    _ParameterPtr m_MkiTrueParam,m_MkiFalseParam,m_MkiSelectParam;
    _ParameterPtr m_DispUpdtParam,m_CurrUpdtTSParam,m_UsrCodeParam,m _CurrUpdtDateParam ,m_MTMPdtParam ;
    _ParameterPtr m_PartIDParam,m_DispParam,m_CurrTSParam,m_PricePar am,m_CurrDateParam,m_ExchParam,m_PdtParam,m_insMki Param,m_DerviParam,m_LTPParam,m_LevelParam,m_Proce ssParam;

    int main(int argc, char* argv[])
    long dwNoOfBackUps =1;
    m_DBHandler = new CDBHandler();

    //Calls SQLDriverConnect


    char lStartTime[50];
    char lEndTime[50];

    printf("Start Timesatmp %s \n", lStartTime);

    printf("before for loop\n");
    for (int i = 0; i < 100; i++)
    printf("Start Timesatmp %s \n", lEndTime);

    HANDLE hEvent;
    hEvent = CreateEvent( NULL, FALSE, FALSE, NULL);
    printf("before wait for single object\n");
    printf("after wait for single object");
    return 0;

    void GetNSOdbc_time_stamp(char *timedate)
    struct tm *today;
    time_t ltime;
    char time_string[40];
    struct _timeb timebuffer;
    char *timeline;

    timeline = ctime(& ( timebuffer.time ));

    time( &ltime );

    today = localtime( &ltime );

    strftime(time_string, sizeof (time_string), "%Y-%m-%d %H:%M:%S", today);
    sprintf(timedate,"%s.%ld",time_string,timebuffer.m illitm);


    BOOL PrepareMPSUpdate()
    _bstr_t getInvs;
    getInvs = "update m_p_s set mps_total_traded_qty = ? where mps_mkt_instr_no = ?";
    m_GetInvsCommand.CreateInstance(__uuidof(Connectio n));
    m_GetInvsCommand->ActiveConnection = m_DBHandler->mConnection ;
    m_GetInvsCommand->CommandText = getInvs;
    m_Qty = m_GetInvsCommand->CreateParameter( "",adChar,adParamInput,10);
    m_MkiNum = m_GetInvsCommand->CreateParameter( "",adChar,adParamInput,10);;
    m_GetInvsCommand->Parameters->Append( m_Qty);
    m_GetInvsCommand->Parameters->Append( m_MkiNum);
    return TRUE;

    BOOL PrepareMPSUpdate1()
    _bstr_t getInvs1;
    getInvs1 = "update m_p_s set mps_t_trad_qty = ? where mps_mkt_instr_no = ?";
    m_GetInvsCommand1.CreateInstance(__uuidof(Command) );
    m_GetInvsCommand1->ActiveConnection = m_DBHandler->mConnection ;
    m_GetInvsCommand1->CommandText = getInvs1;
    m_Qty1 = m_GetInvsCommand1->CreateParameter( "",adChar,adParamInput,10);
    m_MkiNum1 = m_GetInvsCommand1->CreateParameter( "",adChar,adParamInput,10);;
    m_GetInvsCommand1->Parameters->Append( m_Qty1);
    m_GetInvsCommand1->Parameters->Append( m_MkiNum1);
    return TRUE;

    BOOL UpdateMPS()
    long lqyt,lmkino;
    char lExeTime[50];

    lqyt = 100;
    lmkino = 22;
    m_Qty->Value = _variant_t(lqyt);
    m_MkiNum->Value = _variant_t(lmkino);
    m_GetInvsCommand->Execute( NULL, NULL, adCmdText );
    printf("Execute Successfull %s \n",lExeTime);
    catch(_com_error &lError)
    throw lError;
    return true;

  4. #4
    Join Date
    Apr 2006
    may be i should make my question it less complicated.22 views and no replies...

    1 question on ADO's method pAdoCommand->putref_ActiveConnection
    which has one argument the connection.Any chance that it should call for a connection again(Call SQLDriverConnect) ,Even if the object is a valid one..

Posting Permissions

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