How to setting ConnectionString of LinqtoSql's dbml
-
I Drop Table from servermanagent to dbml file. Then I use linqDataSource bind GridView is OK. but I run in another computer, report exception: not find right SqlServer or SqlInstance. I found the .designer.cs file get ConnectionString from settings file, so I changed it ,get connectionstring from web.config, but the same exception also happen. How do I ? Thanks.
-
I Drop Table from servermanagent to dbml file. Then I use linqDataSource bind GridView is OK. but I run in another computer, report exception: not find right SqlServer or SqlInstance. I found the .designer.cs file get ConnectionString from settings file, so I changed it ,get connectionstring from web.config, but the same exception also happen. How do I ? Thanks.
Is the SQLServer available on that other machine? Have you tried using the SQL management to connect to your db? If your Server is installed on your computer than it won't find it on your friend computer. Some work needs to be done. As well as check the ports in use by SQL => maybe they are firewalled. And many other. If it's just a test project so that you can learn/exercise I sugest you use the File Based Approach from the SQL Express. That way you can just copy the .mdf file with your binaries.
modified on Tuesday, March 9, 2010 1:36 PM
-
I Drop Table from servermanagent to dbml file. Then I use linqDataSource bind GridView is OK. but I run in another computer, report exception: not find right SqlServer or SqlInstance. I found the .designer.cs file get ConnectionString from settings file, so I changed it ,get connectionstring from web.config, but the same exception also happen. How do I ? Thanks.
Establish a connection string in your app.config Then your calls to the database will be as follows: using ( MyContext context = new MyContext( ConfigurationManager.ConnectionStrings["mydb"].connectionstring)) { }