基于共享使用SQL Server数据库 [英] Using SQL Server Database on sharing basis

查看:72
本文介绍了基于共享使用SQL Server数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我的应用程序需要在共享网络上运行.来自不同计算机的不同连接会同时访问数据库. SSCE 3.5出现文件共享冲突错误.

我添加了.mdf文件并尝试了该应用程序,但该应用程序未在第二台计算机上运行.
我是否需要以某种方式设置SQL Server Express?

谢谢

Hi,
My application needs to run on a sharing network. Different connections from different computers hit database at the same time. SSCE 3.5 gives File sharing violation error.

I added .mdf file and tried the application but it did not run on second computer.
Do I need to setup SQL Server Express in a certain way?

Thanks

推荐答案

单个SQL Server实例只能使用MDF文件.

只需连接到其他计算机的SQL Server的IP地址或计算机名称,而不是为每个计算机附加MDF文件.



假设computernameoftheserver是托管数据库的名称,而dbname是您的数据库名称:
A single instance of SQL server can use a MDF file only.

Just connect to the IP address or computer name of your SQL server for the other machines instead of attaching a MDF file for each.



Assuming computernameoftheserver is name of the hosting database and dbname is your database name :
SqlConnection con = new SqlConnection("data source=computernameoftheserver;integrated security=sspi; initial catalog=dbname;");
con.Open();
SqlDataAdapter sda = new SqlDataAdapter("select * from tablename", con);
Dataset ds;
sda.Fill(ds);


这篇关于基于共享使用SQL Server数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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