If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Other > ODBC behaviour with Windows messaging API

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-20-06, 07:40
impedementa impedementa is offline
Registered User
 
Join Date: Apr 2006
Posts: 3
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?
Reply With Quote
  #2 (permalink)  
Old 04-20-06, 08:45
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,613
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?

-PatP
Reply With Quote
  #3 (permalink)  
Old 04-20-06, 09:00
impedementa impedementa is offline
Registered User
 
Join Date: Apr 2006
Posts: 3
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;

}MKIPrice;

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

m_DBHandler->CreateConnection();
m_DBHandler->OpenConnection();

PrepareMPSUpdate();
PrepareMPSUpdate1();
char lStartTime[50];
char lEndTime[50];

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

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

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


void GetNSOdbc_time_stamp(char *timedate)
{
struct tm *today;
time_t ltime;
char time_string[40];
memset(time_string,'\0',40);
struct _timeb timebuffer;
char *timeline;

_ftime(&timebuffer);
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_GetInvsCommand->PutPrepared(true);
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_GetInvsCommand1->PutPrepared(true);
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);
try
{
m_GetInvsCommand->Execute( NULL, NULL, adCmdText );
GetNonStopOdbc_time_stamp(lExeTime);
printf("Execute Successfull %s \n",lExeTime);
}
catch(_com_error &lError)
{
throw lError;
}
return true;
}
Reply With Quote
  #4 (permalink)  
Old 04-21-06, 07:53
impedementa impedementa is offline
Registered User
 
Join Date: Apr 2006
Posts: 3
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..
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On