连接到SQL Server [英] Connect to SQL Server

查看:87
本文介绍了连接到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文件?

再次感谢

解决方案

你可以访问网站connectionstrings.com并获取一个连接字符串以供访问数据库


我希望以下讨论点可以帮到你。

http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/9549ab93-9c4e-4681-9d79-d7d13e8d7b42

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

解决方案

you can go the site connectionstrings.com and get a connection string for access database


I hope following discussion points will help you.
http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/9549ab93-9c4e-4681-9d79-d7d13e8d7b42


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆