I’m just starting to learn C# and ASP.NETMVC, but every example I’ve found puts the database in the App_Data folder. I don’t want to do this.
I’d like to create a new version of Nerd Dinner and move the connection string to the web.config, but I can’t find any examples on how to do it. My database is called NerdDinner and I’m using SQL Server Express.
What’s the correct syntax to add the new connection string to my web config? Does this have any effect on creating LINQ to SQL classes?
I always go to http://www.connectionstrings.com/ when I forget how a connectionstring is written.
Standard security SQL Server 2008
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;Here is an article on MSDN talking about How to: Read Connection Strings from the Web.config.
You have a section almost at the top in your
Web.configcalled connectionstrings, it could look something like this:I would recommend however that you also look in to Entity Framework which is an abstraction between your code and the database, it makes it easier to work with “objects” in your database. You can find an introduction to ADO.NET Entity Framework here. But first of all you should focus on getting your connection up and running to your database using the information at the top.