Database connection in c#

Database connection in c#

 

Database operations using system.data.SqlClient namespace in C#.

In this connection string,

     Server - Name of the server to connect to. 

     Database - This is the name of the database you are connecting to. 

 

using(SqlConnection conn = new SqlConnection()) 
{  
    conn.ConnectionString = "Server=server_name;Database=database_name;Trusted_Connection=true";  
    // using the code here...  
}  

 Connection String with id and password

private string MyConnectionString = "Data Source=server_name;Initial Catalog=Database_Name;User Id=sa;Password=*************";//.ConnectionString;

2021-10-03