Jump to content
  • Advertisement
Sign in to follow this  
kag1

ADO in C++ Not Connecting

This topic is 4868 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;

Conn.CreateInstance(__uuidof(Connection));

string ConnStr = "Provider=SQLOLEDB;Data Source=my.mssql.com;Initial Catalog=my_db_name;User Id=my_userid;Password=my_db_password;" ;

try
{
Conn->Open(BSTR(ConnStr.c_str()), BSTR("my_userid"), BSTR("my_db_password"), adOpenUnspecified);
}
catch (_com_error&)
{
::CoUninitialize();
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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!