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?
Asked
Active
Viewed 864 times
-6
-
6There 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. – Davin Tryon Jan 31 '15 at 22:33
-
1possible duplicate of [How to create a connection string in asp.net c#](http://stackoverflow.com/questions/22113751/how-to-create-a-connection-string-in-asp-net-c-sharp) – Nazmul Hossain Jan 31 '15 at 22:50
3 Answers
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.

parek
- 772
- 1
- 13
- 41
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 ...

ako
- 179
- 7
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..

mickl
- 48,568
- 9
- 60
- 89

Mohan Kamargiri
- 1
- 2
-
Thanks for editting and formatting it...I'll take care from next time..@mickl – Mohan Kamargiri Mar 01 '18 at 06:09