本文介绍了连接到SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi eveyone

玩得开心



i希望连接到sql server数据库,所以我使用下面的代码,我得到了结果它的工作原理。



 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'其中name ='milk' ));
MessageBox(_T( done。));
}





但我需要连接到附加的mdf文件。

i写道attachdbfilename = G:\\shop.mdf在连接字符串中,但是没有工作并返回错误。



你可以帮助我吗?我怎么能连接到CDatabase的mdf文件?

再次感谢

解决方案



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.

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

解决方案



这篇关于连接到SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 00:02