Solved

Problem/Question about Assertion Error in Atldbcli.h

Posted on 2004-10-27
701 Views
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;
        break;
    }
    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?

Thanks,
Jeff
0
Question by:jpetter
    5 Comments
     
    LVL 86

    Accepted Solution

    by:
    >>    // 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...
    0
     

    Author Comment

    by:jpetter
    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.

    Thanks,
    Jeff
    0
     

    Author Comment

    by:jpetter
    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?

    Thanks,
    Jeff
    0
     
    LVL 86

    Expert Comment

    by:jkr
    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')
    0
     

    Author Comment

    by:jpetter
    jkr,

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

    Jeff
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Course: From Zero to Hero with Nodejs & MongoDB

    Interested in Node.js, but don't know where to start or how to learn it properly? Confused about how the MEAN stack pieces of MongoDB, Expressjs, Angularjs, and Nodejs fit together? Or how it's even possible to run JavaScript outside of the browser?

    Suggested Solutions

    Title # Comments Views Activity
    Motorola device cold boot 3 301
    only14 challenge 19 50
    withoutTen challenge 14 50
    scoreUp challenge 14 26
    Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    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.
    Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    875 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

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now