Click here to Skip to main content
16,013,747 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi eveyone
have a good time

i want to connect to sql server database, so i use below code and i got result and it works.

C++
CDatabase db;
if (db.OpenEx(_T("Driver={SQL Server Native Client 11.0};Server=.;Database=m;Trusted_Connection=yes;"),4)){
	db.ExecuteSQL(_T("update dbo.items set count='200' where name='milk'"));
    MessageBox(_T("done."));                  
}


but i need to connect to attached mdf file.
i wrote "attachdbfilename=G:\\shop.mdf" in connection string, but that didn't work and returned an error.

can you help me?how can i connect to a mdf file with CDatabase?
thanks again
Posted

you can go the site connectionstrings.com and get a connection string for access database
 
Share this answer
 
Comments
[no name] 22-Dec-12 4:33am    
thanks
but i used related connection strings but it did'nt work.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900