1

I can't find a decent tutorial/blog that has a solution for my problem.

On my laptop I run a Microsoft SQLServer named 'SQLSERVER'. There's a database in it called 'SalesDB'. I can't figure out how to fill in the Data Source property of the ConnectionString in the web.config file in my ASP.NET MVC 4 application to get my application connected with the database.

This is the default connectionstring:

<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-Labo7SQL-20131226161445;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-Labo7SQL-20131226161445.mdf" />

2 Answers 2

4

connectionstrings.com tends to be a pretty useful resource for formatting a connection string. For MS SQL Server, you have a few options. Such as:

Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;

or

Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;

or

Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;Password=myPassword;

Using the last one as an example, yours might be something like:

Server=localhost\SQLSERVER;Database=SalesDB;User Id=myUsername;Password=myPassword;
Sign up to request clarification or add additional context in comments.

Comments

0

The Data Source value should be the name (or ip address) of your sql sever. The Initial Catalog value should be the name of your database...SalesDB and you should remove the AttachDBFilename

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.