SQL Server Implementation steps


 SQL Server Implementation:

 1.Import the Library (at the top):
   using System.Data.SqlClient;
 2.Construct the “Connection” class object:
   SqlConnection cn = new SqlConnection();
 3.Assign the Connection string:
   cn.ConnectionString = "data source=<name of the server>;user id=<user name>;password=<password>;initial catalog=<database name>";
 4.Open the connection:
   cn.Open();
 5.Construct the “Command” class object:
   SqlCommand cmd = new SqlCommand();
 6.Assign the reference of “Connection” class object to “Command” class object:
   cmd.Connection = cn;
 7.Assign the procedure / function name that is to be executed:
   cmd.CommandText = "xxxxx";
 8.Assign the command type to “Command” class object:
   cmd.CommandType = CommandType.StoredProcedure;
 9.Assign the parameters (if any) to the “Command” class object:
   cmd.Parameters.AddWithValue("parameter_name", value); ………………….; ………………….;
 10.Execute the procedure / function:
   cmd.ExecuteNonQuery();
 11.Close the connection:
   cn.Close();






Subscribe

Receive Quality Tutorials Straight in your Inbox by submitting your Email below:

Delivered by FeedBurner

Protected by Copyscape Duplicate Content Checker