无法访问服务器计算机中的SQL Server文件 [英] Can't access SQL Server file in the server machine

查看:108
本文介绍了无法访问服务器计算机中的SQL Server文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在服务器计算机上设置了我的WCF服务。

I setup the my WCF service on server machine.

服务器操作系统是带有SQL Server 2008 Express的Windows 2008。

The server OS is Windows 2008 with SQL Server 2008 Express.

我正在尝试访问我的SQL Server(mdf)文件以使用LINQ to SQL读取数据。

I am trying to access to my SQL Server (mdf) file to read data using LINQ to SQL.

我看到DataContext没问题 - 但是当我尝试获取其中一个表中的信息时我得到了一个异常

I see that the DataContext is OK - but when I try to get information that in one of the table I get an exception


由于
检索用户的本地
应用程序数据路径失败,无法生成
SQL Server的用户实例。请确保用户在计算机上拥有本地用户配置文件

。连接将
关闭。

Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.

我不知道我需要在IIS 7.5中定义或更改我在服务器端使用。

I don't know what i need to define or change in the IIS 7.5 that I'm using in the server side.

感谢您的帮助。

更新:与数据库文件的连接很好 - 但从表中获取信息是一个例外。连接字符串是:

Update: the connection to the database file is fine - but getting information from table is thru an exception. The connection string is:

Data Source=.;AttachDbFilename=|DataDirectory|\ServiceData.mdf;
  Integrated Security=SSPI;User Instance=True


推荐答案

如果您已经有服务器,为什么不将MDF连接到运行的SQL Server(Express),然后像服务器上的普通数据库一样使用它?

If you already have a server, why don't you just attach the MDF to the SQL Server (Express) running, and then use it like a normal database on your server?

执行此操作后,请使用以下连接字符串:

After you do this, use a connection string like:

server=Server\SQLExpress;Database=YourDatabaseName;Integrated Security=SSPI

我从不喜欢 AttachDbFileName = 用户实例方法 - 对我来说似乎是一个(不可靠)的黑客攻击,如果你在服务器上运行,这真的没有用。

I never quite liked the AttachDbFileName= and User Instance approach - seems like a (unreliable) hack to me, which really doesn't make sense if you're running on a server machine.

这篇关于无法访问服务器计算机中的SQL Server文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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