Showing posts with label adodb. Show all posts
Showing posts with label adodb. Show all posts

Monday, March 19, 2012

connection issues when running multiple instances of same application

I am running multiple instance of the same application. This application is connecting to the database and running stored procedures using ADODB (all code examples are taken from msado15).

The problem is that somehow these two applications are sharing something either with the connection or commands.

For instance if the two instances are in the following function at the same time then they both thow an SEH exception:

Code Snippet

inline _RecordsetPtr Command15::Execute ( VARIANT * RecordsAffected, VARIANT * Parameters, long Options ) {

struct _Recordset * _result = 0;

HRESULT _hr = raw_Execute(RecordsAffected, Parameters, Options, &_result);

if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));

return _RecordsetPtr(_result, false);

}

The exception that occurs is: "First-chance exception ...: 0xC0000005: Access violation reading location 0x00000068."

And afterwords when they go to release the command an error occurs on

First-chance exception at 0x4de4120c in IpsEngine.exe: 0xC0000005: Access violation reading location 0xcccccccc.

Code Snippet

inline void _bstr_t::Data_t::_Free() throw()

{

if (m_wstr != NULL) {

::SysFreeString(m_wstr);

}

if (m_str != NULL) {

delete [] m_str;

}

}

This is being called from.

Code Snippet

inline void Command15::PutRefActiveConnection ( struct _Connection * ppvObject ) {

HRESULT _hr = putref_ActiveConnection(ppvObject);

if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));

}

The exception that occurs: First-chance exception at ...: 0xC0000005: Access violation reading location 0xcccccccc.

Similarly when one instance releases a command using

Code Snippet

inline void Command15::PutRefActiveConnection ( struct _Connection * ppvObject ) {

HRESULT _hr = putref_ActiveConnection(ppvObject);

if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));

}

The second instance of the application fails when running the command at the exact same time.

Code Snippet

inline _RecordsetPtr Command15::Execute ( VARIANT * RecordsAffected, VARIANT * Parameters, long Options ) {

struct _Recordset * _result = 0;

HRESULT _hr = raw_Execute(RecordsAffected, Parameters, Options, &_result);

if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));

return _RecordsetPtr(_result, false);

}

The command and connections are not static and there should be completely seperate instances of these for each instance of the application. Does anybody know why this may be happening. Any help would be appreciated. Thanks in advance.

All of these access issues are with pointers being passed into these functions. As such, we don't have much context with which to help you with these issues. Any issue could be causing these problems including: double freeing, not allocating memory elsewhere or failure to properly initialize memory, failure to check return codes of functions that return memory, etc. In these cases, we need to see the context surrounding the variables that are causing the AV, in for example: for Command15::Execute, RecordsAffected and Parameters would be the variables of interest, we would need to see how they are allocated, initialized, and used prior to this function call in the execution context of a failure, and how they are allocated, initialized, and used prior to this function call in the execution context of success. The most likely cause of this AV is failure to handle error conditions coming back from functions that allocate memory on success.

Thanks,

John

|||

But when I run only one instance of the application at a time it works fine, I have been running it already for a long time and never had a problem. How is it that running two seperate instances of the application could cause this error. The memory allocation would not change just because there are two instances? would it?

connection issues when running multiple instances of same application

I am running multiple instance of the same application. This application is connecting to the database and running stored procedures using ADODB (all code examples are taken from msado15).

The problem is that somehow these two applications are sharing something either with the connection or commands.

For instance if the two instances are in the following function at the same time then they both thow an SEH exception:

Code Snippet

inline _RecordsetPtr Command15::Execute ( VARIANT * RecordsAffected, VARIANT * Parameters, long Options ) {

struct _Recordset * _result = 0;

HRESULT _hr = raw_Execute(RecordsAffected, Parameters, Options, &_result);

if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));

return _RecordsetPtr(_result, false);

}

The exception that occurs is: "First-chance exception ...: 0xC0000005: Access violation reading location 0x00000068."

And afterwords when they go to release the command an error occurs on

First-chance exception at 0x4de4120c in IpsEngine.exe: 0xC0000005: Access violation reading location 0xcccccccc.

Code Snippet

inline void _bstr_t::Data_t::_Free() throw()

{

if (m_wstr != NULL) {

::SysFreeString(m_wstr);

}

if (m_str != NULL) {

delete [] m_str;

}

}

This is being called from.

Code Snippet

inline void Command15::PutRefActiveConnection ( struct _Connection * ppvObject ) {

HRESULT _hr = putref_ActiveConnection(ppvObject);

if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));

}

The exception that occurs: First-chance exception at ...: 0xC0000005: Access violation reading location 0xcccccccc.

Similarly when one instance releases a command using

Code Snippet

inline void Command15::PutRefActiveConnection ( struct _Connection * ppvObject ) {

HRESULT _hr = putref_ActiveConnection(ppvObject);

if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));

}

The second instance of the application fails when running the command at the exact same time.

Code Snippet

inline _RecordsetPtr Command15::Execute ( VARIANT * RecordsAffected, VARIANT * Parameters, long Options ) {

struct _Recordset * _result = 0;

HRESULT _hr = raw_Execute(RecordsAffected, Parameters, Options, &_result);

if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));

return _RecordsetPtr(_result, false);

}

The command and connections are not static and there should be completely seperate instances of these for each instance of the application. Does anybody know why this may be happening. Any help would be appreciated. Thanks in advance.

All of these access issues are with pointers being passed into these functions. As such, we don't have much context with which to help you with these issues. Any issue could be causing these problems including: double freeing, not allocating memory elsewhere or failure to properly initialize memory, failure to check return codes of functions that return memory, etc. In these cases, we need to see the context surrounding the variables that are causing the AV, in for example: for Command15::Execute, RecordsAffected and Parameters would be the variables of interest, we would need to see how they are allocated, initialized, and used prior to this function call in the execution context of a failure, and how they are allocated, initialized, and used prior to this function call in the execution context of success. The most likely cause of this AV is failure to handle error conditions coming back from functions that allocate memory on success.

Thanks,

John

|||

But when I run only one instance of the application at a time it works fine, I have been running it already for a long time and never had a problem. How is it that running two seperate instances of the application could cause this error. The memory allocation would not change just because there are two instances? would it?

Sunday, March 11, 2012

Connection for windows authorization

I have a vb script that uses odbc.connection that connects to the sql
server, snippet as shown:
szADOConnObjID = "ADODB.Connection";
set pADOConnObj = CreateObject(szADOConnObjID);
// Create the SQL string to complete the connection
szConnString = "driver={" + svDriver + "};";
szConnString = szConnString + "server=" + svServerName + ";";
if (g_bWinAuth = FALSE) then
szConnString = szConnString + "database=master;";
szConnString = szConnString + "uid=" + svUserName + ";";
szConnString = szConnString + "pwd=" + svUserPassword;
else // windows authorization
szConnString = szConnString + "Initial Catalog=master;";
szConnString = szConnString + "Integrated security=True";
endif;
// Open the ADO Connection
pADOConnObj.Open(szConnString);
I have no problem with the login with uid-pwd. However, if I use windows
authorization, I got the following error:
Microsoft OLE DB Service Components (0x80040E21)
Multiple-step OLE DB operation generated errors. Check each OLE DB
status value, if available.
Is my connection string correct?
TIA.Hi
I assume you can use a trusted connection from other application with this
login?
Try the connection string
Driver={SQL
Server};Server=myServerAddress;Database=myDataBase;Trusted_Connection=Yes;
as described for an ODBC connection in:
http://www.connectionstrings.com/?carrier=sqlserver
John
"Light" wrote:
> I have a vb script that uses odbc.connection that connects to the sql
> server, snippet as shown:
> szADOConnObjID = "ADODB.Connection";
> set pADOConnObj = CreateObject(szADOConnObjID);
> // Create the SQL string to complete the connection
> szConnString = "driver={" + svDriver + "};";
> szConnString = szConnString + "server=" + svServerName + ";";
> if (g_bWinAuth = FALSE) then
> szConnString = szConnString + "database=master;";
> szConnString = szConnString + "uid=" + svUserName + ";";
> szConnString = szConnString + "pwd=" + svUserPassword;
> else // windows authorization
> szConnString = szConnString + "Initial Catalog=master;";
> szConnString = szConnString + "Integrated security=True";
> endif;
> // Open the ADO Connection
> pADOConnObj.Open(szConnString);
> I have no problem with the login with uid-pwd. However, if I use windows
> authorization, I got the following error:
> Microsoft OLE DB Service Components (0x80040E21)
> Multiple-step OLE DB operation generated errors. Check each OLE DB
> status value, if available.
> Is my connection string correct?
> TIA.
>|||Hi Light,
You may try John's suggestion first. Also, I would like to know:
What is the result if you change your code for windows authentication to
the following code:
szConnString = szConnString + "database=master;";
szConnString = szConnString + "Integrated security=SSPI";
Hope this helps. Please feel free to let me know if you have any questions
or concerns.
Best regards,
Charles Wang
Microsoft Online Community Support
=====================================================When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================|||Hi John and Charlies,
The solution from John works but the SSPI doesn't.
As long as one of them works, I am happy. However, I would like to know the
difference between them though.
Thanks for all your helps.
Cheers.
"Charles Wang[MSFT]" <changliw@.online.microsoft.com> wrote in message
news:XyodACw4HHA.4200@.TK2MSFTNGHUB02.phx.gbl...
> Hi Light,
> You may try John's suggestion first. Also, I would like to know:
> What is the result if you change your code for windows authentication to
> the following code:
> szConnString = szConnString + "database=master;";
> szConnString = szConnString + "Integrated security=SSPI";
> Hope this helps. Please feel free to let me know if you have any questions
> or concerns.
> Best regards,
> Charles Wang
> Microsoft Online Community Support
> =====================================================> When responding to posts, please "Reply to Group" via
> your newsreader so that others may learn and benefit
> from this issue.
> ======================================================> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> ======================================================>|||Hi Light,
After I dicussed this issue with an ADO expert, this issue was related to
the driver option specified in your connection string. ODBC driver does not
recognize "integrated security" option.
If you use SQL OLEDB provider for the connection string
"Provider=sqloledb;server=CharlesXP;database=Test;Integrated
security=SSPI", it will work fine.
You may refer to:
ADO Connection Strings
http://www.codeproject.com/database/connectionstrings.asp
If you have any other questions or concerns, please feel free to let me
now. Have a nice day!
Best regards,
Charles Wang
Microsoft Online Community Support
======================================================When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================|||Thanks Charlies.
This is nice info to have.
"Charles Wang[MSFT]" <changliw@.online.microsoft.com> wrote in message
news:6WMHNf04HHA.4200@.TK2MSFTNGHUB02.phx.gbl...
> Hi Light,
> After I dicussed this issue with an ADO expert, this issue was related to
> the driver option specified in your connection string. ODBC driver does
> not
> recognize "integrated security" option.
> If you use SQL OLEDB provider for the connection string
> "Provider=sqloledb;server=CharlesXP;database=Test;Integrated
> security=SSPI", it will work fine.
> You may refer to:
> ADO Connection Strings
> http://www.codeproject.com/database/connectionstrings.asp
> If you have any other questions or concerns, please feel free to let me
> now. Have a nice day!
> Best regards,
> Charles Wang
> Microsoft Online Community Support
> ======================================================> When responding to posts, please "Reply to Group" via
> your newsreader so that others may learn and benefit
> from this issue.
> ======================================================> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> ======================================================>|||Hi Light,
I am glad to hear that the suggestions are helpful. If you have any other
qeustions or concerns, please feel free to let us know.
Have a great day!
Best regards,
Charles Wang
Microsoft Online Community Support
=====================================================When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================