An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces,
error: 25 - Connection string is not valid)
Thanks
I love computers because: MY WISH IS THEIR COMMAND :)
Are you using the right connection string in your LINQ to SQL model? Check the constructors from the generated code and see if they are referring to the correct connection string from web.config.
If you do not have SQL Server Express installed then you cannot use an .mdf file from your App_Data folder. You can test if you have SQL Server Express installed by checking if you have a SQL Server instance called "SQLEXPRESS" installed on your machine.
You can also connect to a full SQL Server instance using the Server tab. Import the .mdf file into your SS, create a new LINQ to SQL model (via Add new Item), and then drop tables from your server onto the designer surface.
I have been avoiding LINQ bandwagon so far as I do all my DB processing thru' TableAdapters. So if LINQ is required for this, can you please step me thru' the process.
Thanks
I love computers because: MY WISH IS THEIR COMMAND :)
yaip
Contributor
4785 Points
1229 Posts
ConnectionString to access .mdf file in App_Data folder
Apr 10, 2008 11:25 PM|LINK
I have AddressBook.mdf file in my website's App_Data folder. I have to following ConnectionString in my web.config:
<connectionStrings>
<add name="AddressBookConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\AddressBook.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
How do I change it to access the file in App_Data folder? What should my new ConnectionString be?
I love computers because: MY WISH IS THEIR COMMAND :)
<Website>
<Gadget>
marcind
Contributor
3344 Points
609 Posts
Microsoft
Re: ConnectionString to access .mdf file in App_Data folder
Apr 10, 2008 11:55 PM|LINK
Hi,
the |DataDirectory| token already refers to the App_Data folder so everything should just work. Are you having any specific issues?
ASP.NET Team
@marcind
Blog
yaip
Contributor
4785 Points
1229 Posts
Re: ConnectionString to access .mdf file in App_Data folder
Apr 11, 2008 12:09 AM|LINK
I am getting:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 25 - Connection string is not valid)
I love computers because: MY WISH IS THEIR COMMAND :)
<Website>
<Gadget>
marcind
Contributor
3344 Points
609 Posts
Microsoft
Re: ConnectionString to access .mdf file in App_Data folder
Apr 11, 2008 12:16 AM|LINK
Are you using the right connection string in your LINQ to SQL model? Check the constructors from the generated code and see if they are referring to the correct connection string from web.config.
ASP.NET Team
@marcind
Blog
yaip
Contributor
4785 Points
1229 Posts
Re: ConnectionString to access .mdf file in App_Data folder
Apr 11, 2008 12:23 AM|LINK
This is just a sample I downloaded from here:
http://code.msdn.microsoft.com/dynamicdata/Release/ProjectReleases.aspx?ReleaseId=850
I am just trying to run it in VS 2008 without any modifications.
I love computers because: MY WISH IS THEIR COMMAND :)
<Website>
<Gadget>
scothu
Participant
1436 Points
291 Posts
Microsoft
Moderator
Re: ConnectionString to access .mdf file in App_Data folder
Apr 11, 2008 12:41 AM|LINK
Do you have SQL Server Express installed? The sample is assuming that.
Scott
PM, ASP.NET Team, Microsoft
yaip
Contributor
4785 Points
1229 Posts
Re: ConnectionString to access .mdf file in App_Data folder
Apr 11, 2008 01:02 AM|LINK
No. I have SS 2005. What changes do I need to make to my ConnectionString?
I love computers because: MY WISH IS THEIR COMMAND :)
<Website>
<Gadget>
marcind
Contributor
3344 Points
609 Posts
Microsoft
Re: ConnectionString to access .mdf file in App_Data folder
Apr 11, 2008 01:08 AM|LINK
If you do not have SQL Server Express installed then you cannot use an .mdf file from your App_Data folder. You can test if you have SQL Server Express installed by checking if you have a SQL Server instance called "SQLEXPRESS" installed on your machine.
You can also connect to a full SQL Server instance using the Server tab. Import the .mdf file into your SS, create a new LINQ to SQL model (via Add new Item), and then drop tables from your server onto the designer surface.
ASP.NET Team
@marcind
Blog
yaip
Contributor
4785 Points
1229 Posts
Re: ConnectionString to access .mdf file in App_Data folder
Apr 11, 2008 01:27 AM|LINK
I have been avoiding LINQ bandwagon so far as I do all my DB processing thru' TableAdapters. So if LINQ is required for this, can you please step me thru' the process.
I love computers because: MY WISH IS THEIR COMMAND :)
<Website>
<Gadget>
yaip
Contributor
4785 Points
1229 Posts
Re: ConnectionString to access .mdf file in App_Data folder
Apr 11, 2008 01:45 AM|LINK
If I do Control Panel->Administrative Tools->Services, I see SQL Server (SQLEXPRESS). However, I don't see it under Add or Remove Programs.
I love computers because: MY WISH IS THEIR COMMAND :)
<Website>
<Gadget>