Is this function a thread procedure? Then you need to CoUnitialize before
returning.
If it's not a thread proc, you should not CoInitialize here.
Willy.
"ashish_chap" <as****************@mail.codecomments.com> wrote in message
news:as****************@mail.codecomments.com...
|
| Hi,
|
| I am using _bstr_t class in a function. This is used in an application
| that is used in an multi-threaded environment. The function is
| implemented as follows:
|
| int Function(wchar_t *sqlCmd)
| {
| _bstr_t cmd ;
|
| cmd = sqlCmd ;
| CoInitialize(NULL);
| .
| .
| .
| return 0;
| }
|
|
| The above function uses ADO functions to execute SQL command. Here, in
| statement
|
| cmd = sqlCmd
|
| while executing sqlCmd "Sometimes" an exception is thrown this happens
| because though sqlCmd contains the sqlCmd to be executed. It is not
| assigned to cmd which is passed to Execute function of ADODB.
|
| Also, it crashes sometimes when the function returns and destructor for
| _bstr_t is called.
|
| Please, help me find out the answers to the following questions.
| 1) Is there any limitation for the overloaded '=' operation in _bstr_t,
| due to which somestimes the sqlCmd is not assigned to cmd.
|
| 2)Before calling the destructor for _bstr_t is there any operation that
| should be used to avoid the crash?
|
| Thanks for you time.
|
| Regards,
| Ashish Choudhary
|
|
|
| --
| ashish_chap
| ------------------------------------------------------------------------
| Posted via
http://www.codecomments.com
| ------------------------------------------------------------------------
|