Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Problem/Question about Assertion Error in Atldbcli.h

Posted on 2004-10-27
Medium Priority
Last Modified: 2013-11-20
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?

Question by:jpetter
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 86

Accepted Solution

jkr earned 2000 total points
ID: 12423674
>>    // 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...

Author Comment

ID: 12423742
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.


Author Comment

ID: 12424200
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?

LVL 86

Expert Comment

ID: 12424410
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')

Author Comment

ID: 12432596

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


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question