// Create a new object of SqlConnection Class
SqlConnection Con = new SqlConnection();
// Assign ConnectionString to SqlConnection object
Con.ConnectionString = "Data Source = CDT-LAPSERVER\\CDT2012; Initial Catalog = TestDB; User ID = sa; Password = cyberdyne1234;";
// After assiging ConnectionString to SqlConnection object Open the connection
Con.Open();
// To check the state of connection (open or closed) prompt it in message box
MessageBox.Show("Connection state is : " + Con.State.ToString());
Post a Comment