Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL 2000 connection problem

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0

I am using CDatasource and CSession to gain access to a SQL 2000 database but I have difficulties in connecting to it with a connection string. I have tried many examples from MSDN like:
"Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Initial Catalog=NameofMydatabase;Data Source=name of server"
but it doesn't work.

I appreciate all the help
 
Dear Daig_Burel,

there is no password provided in your connectionstring
The example you posted also uses the sa (systemadministrator) to connect to the database. If it is that there is no password (i.e blank password ) for the sa, THEN CHANGE IT.
And (just in case) you should not connect to the database as sa within your program.

regards Astrid



 
Dear Dajg_Burel,

The connection string seems good to me. Please check in your project for the following to things:

- before trying to open the datasource use the function

CoInitializeEx(NULL, COINIT_MULTITHREADED);

defined in Objbase.h, to initialize the OLEDB component;

-make sure you have defined somewhere before this function the following:

#define _WIN32_DCOM
#define _WIN32_WINNT 0x0400 //(or greater)

to enable the use of that function.

Now, if the connection string contains valid data, you should be able to open your database.

regards,
Mawsh Krah'tchoon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top