Problem/Question about Assertion Error in Atldbcli.h

In one of the utility programs I have written to help with our domain migration project, I use a database lookup function that was essentially written by nabehs as a result of a question I posted here. As a little background information, the lookup is performed against an SQL server, and a SQL username/password is passed in the connection string as opposed to using Windows authentication. This has worked quite well in our testing so far. Until today, and today this was tested on a few machines in another region, which also happen to be in a different resource domain and logon domain from those we previously tested and from the one the SQL server is in. Also, I should add that to avoid or minimize potential dll and lib problems, I statically linked the program. On these machines I receive Debug Assertion Failed! messages, that point to line 3543 of atldbcli.h. The line is:
// Check the session is valid
ATLASSERT(session.m_spOpenRowset != NULL);

and my function (okay, nabehs function) is:
void CQuery1::GetOtherUserId(LPCTSTR szUserId, CString &strOtherUserId)
      CoInitialize (NULL);
      CCommand<CAccessor<CQuery1> > rs;
      CString strConnectionString = "Provider=sqloledb;Data Source=USNYMEN11WXX01;Initial Catalog=US1Migration;User Id=migrationUser;Password=!dataViewer";

      CDataSource ds;
    CSession session;
    HRESULT hr;

      CString strQuery;
    strQuery.Format("SELECT VZID FROM tblIDs WHERE BAID = '%s'", szUserId);
    // without error checking
    hr = ds.OpenFromInitializationString(strConnectionString.AllocSysString( ));
    hr = session.Open(ds);
    hr = rs.Open(session, LPCTSTR(strQuery));
    while(rs.MoveNext( ) == S_OK)
        strOtherUserId = rs.m_szVzid;
    rs.Close( );
    session.Close( );
    ds.Close( );

    CoUninitialize( );

My questions now are: (1) shouldn't statically linking avoid these issues? (2) could this possibly be a domain issue even though I am using SQL authentication (the domains are trusted) and (3) Does anyone have any ideas how I may resolve an issue like this?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

>>    // without error checking
>>   hr = ds.OpenFromInitializationString(strConnectionString.AllocSysString( ));

There's your problem. Presumably, the above fails and you don't check for errors, which is *cough* not a good idea...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jpetterAuthor Commented:
Hahaha....I think you could be on to something....heck, the function worked so well up until now, I never even looked at it.

Let me do some research.

jpetterAuthor Commented:
Hey, btw, with this working on most systems, when it does fail, do you think it is due to the PC/laptop it's running on (a local issue), or is it more likely to be connection oriented?

That could have a lot of reasons. Since you mentioned a 'different logon domain', it could simply be the case that these users don't have access to the machine the server is running on. The HRESULT  code returned should shed in some light (well, if it's not just 'E_FAIL')
jpetterAuthor Commented:

Thanks again...there it was, right in front of my eyes and I was too busy looking for it to see it.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.