LINQ到SQL DB的连接 [英] LINQ to SQL DB Connection
问题描述
大家好,
我已经使用LINQ to SQL创建了服务.在我自己的服务器浏览器中的.dbml类(LINQ to SQL类)的计算机中,我找到了数据库,并将其拖放到该类中.因此,现在VS为我自动创建了连接字符串.我在Settings.seetings和app.config文件中看到了该连接.问题出现在我这里:
我还将在生产服务器中使用此项目.我继续进行操作,并从这些文件中更改了我的连接字符串,甚至还有更多更改.
我之前的连接字符串是:
Hello all,
I have created a service with LINQ to SQL. In my own computer for the .dbml class (LINQ to SQL class) from the Server Explorer I have found the database, drag and dropped it to the class. So now VS created the connection strings automatically for me. I see that in my Settings.seetings and app.config files i can see the connection. The problem arises here for me:
I will also use this project in the production server. I went ahead and changes my connection strings from these files and in couple more.
my previous connection string was:
connectionString="Data Source=PC36\SQLEXPRESS;Initial Catalog=RMA_DB;"
为了使项目在每台计算机上都能正常工作,我已将此连接字符串更改为;
so to make the project work in each computer i have changed this conenction string to;
connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=RMA_DB;"
但是不知何故,它仍然从我的第一个连接读取值.我已经搜索了VS使用此连接字符串的位置并更改了每个连接字符串,但是我不知道为什么项目没有使用已安装的计算机的DB而不是我的数据库.有人可以指出我做错了什么吗?谢谢
But somehow it is still reading the values from my first connection. I have searched where VS uses this connection string and changed each one but i dont know why the project is not using the installed computer''s DB instead of mine. Can someone point me out where I did wrong? Thanks
推荐答案
如果可以的话,请尝试使用此格式...
示例:
Hi,
Try this format if could help...
Example:
<add name="connectionString1" connectionString="Data Source=211.9.0.91\RMA_DB;Initial Catalog=RMA_DB;User ID=DataBaseUserID;Password=DataBasePassword" providerName="System.Data.SqlClient"/>
这篇关于LINQ到SQL DB的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!