Connection String

connection string in c#

You can connect your C# application to data in a SQL Server database using the .NET Framework Data Provider for SQL Server. The first step in a C# application is to create an instance of the Server object and to establish its connection to an instance of Microsoft SQL Server.
The SqlConnection Object is Handling the part of physical communication between the C# application and the SQL Server Database . An instance of the SqlConnection class in C# is supported the Data Provider for SQL Server Database. The SqlConnection instance takes Connection String as argument and pass the value to the Constructor statement.

connetionString="Data Source=ServerName; Initial Catalog=DatabaseName;User ID=UserName;Password=Password"

If you have a named instance of SQL Server, you'll need to add that as well.

 "Server=localhost\sqlexpress"

Connect via an IP address

connetionString="Data Source=IP_ADDRESS,PORT; Network Library=DBMSSOCN;Initial Catalog=DatabaseName; User ID=UserName;Password=Password"

Trusted Connection from a CE device ( 1433 is the default port SQL )

 connetionString="Data Source=ServerName; Initial Catalog=DatabaseName;Integrated Security=SSPI; User ID=myDomain\UserName;Password=Password;

Connecting to SQL Server using windows authentication

 "Server= localhost; Database= employeedetails; Integrated Security=SSPI;"

0 comments:

Post a Comment