Advertisement Jump to content
Sign in to follow this  

ADO in C++ Not Connecting

This topic is 4963 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm brand new to ADO in C++, but I can't get it to connect, here is the connection code I have
#import "c:\program files\common files\system\ado\msado26.tlb" no_namespace rename( "EOF", "A_EOF" )

//..Later On..I took out the real UN, PW, DBNAME, and HOST

HRESULT hr = ::CoInitialize(NULL);
_ConnectionPtr Conn;


string ConnStr = "Provider=SQLOLEDB;Data;Initial Catalog=my_db_name;User Id=my_userid;Password=my_db_password;" ;

Conn->Open(BSTR(ConnStr.c_str()), BSTR("my_userid"), BSTR("my_db_password"), adOpenUnspecified);
catch (_com_error&)
cout << "Error Connectiong";

I'm not quite sure how to check on the errors because I've never really used any com objects (except DX) So anything I'm doing wrong that anyone notices? Thanks, kag1

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!