-6

I'm facing some problems with creating a connection string to my SQL Server database. I'm running Visual Studio 13. I want to connect to the database from a ASP.NET C# application. How should my connection string be formed?

2
  • 6
    There are many only resources that will answer this question. A quick Google will give you many, many options. Do some research on the problem and I'm sure you will find the answer. Commented Jan 31, 2015 at 22:33
  • 1
    possible duplicate of How to create a connection string in asp.net c# Commented Jan 31, 2015 at 22:50

3 Answers 3

1

If you have the database showing in the Server Exporer in Visual Studio you can copy the ConnectionString from it's properties.

However, Connection Strings aren't complicated, of course depending on your database settings, but the basic template looks like this:

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

There's a lot of references about Connection Strings out there, have a look.

Sign up to request clarification or add additional context in comments.

Comments

0

open ServerExplorer in ViEW menue and Right Click On Your DataBase go to Property then there is a ConnectionString I Think that is what you want ...

Comments

0

The basic connectionString looks like-

If you are setting in Code behind file then do this -

string conStr = @"Data Source=ServerName;Initial Catalog=Database;User Id=User;Password=Password";

If want to set in Config file then follow this -

<appSettings>
   <add key="KeyName" value="Data Source=ServerName;Initial Catalog=Database;User Id=User;Password=Password"/>
</appSettings>

Hope it helps..

1 Comment

Thanks for editting and formatting it...I'll take care from next time..@mickl

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.