Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 10th, 2012  |  syntax: None  |  size: 0.94 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using System.Configuration;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4.  
  5. namespace Data.DataAccessLayer.DatabaseOperation
  6. {
  7.    public class CustomersDataBaseOperation
  8.     {
  9.        public static SqlConnection ConnStr
  10.        {
  11.            get { return new SqlConnection(ConfigurationManager.ConnectionStrings["CustomerConnString"].ConnectionString); }
  12.        }
  13.  
  14.  
  15.         public int Insert (Storedprocedure storedprocedure, int id, string name, string mail)
  16.         {
  17.             using (ConnStr)
  18.             {
  19.                 SqlCommand command= new SqlCommand(storedprocedure.ToString(),ConnStr);
  20.  
  21.                 command.CommandType = CommandType.StoredProcedure;
  22.                 command.Parameters.AddWithValue("@ID", id);
  23.                 command.Parameters.AddWithValue("@Name",name);
  24.                 command.Parameters.AddWithValue("@Mail", mail);
  25.  
  26.                 command.Connection.Open();
  27.                 command.ExecuteNonQuery();