Why should we use sql helper class in our application.What difference between sql helper class and simple class.In which situation sql Helper should used.Please define structure of class.
SqlHelper
is intended to consolidate mundane, repetitive code that is written time and time again in data access layer components of ADO.NET applications, like this:
using Microsoft.ApplicationBlocks.Data;
SqlHelper.ExecuteNonQuery(connection,"INSERT_PERSON",
new SqlParameter("@Name",txtName.Text),
new SqlParameter("@Age",txtAge.Text));
Instead of this:
string connectionString = (string)
ConfigurationSettings.AppSettings["ConnectionString"];
SqlConnection connection = new SqlConnection(connectionString);
SqlCommand command = new SqlCommand("INSERT_PERSON",connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@Name",SqlDbType.NVarChar,50));
command.Parameters["@Name"].Value = txtName.Text;
command.Parameters.Add(new SqlParameter("@Age",SqlDbType.NVarChar,10));
command.Parameters["@Age"].Value = txtAge.Text;
connection.Open();
command.ExecuteNonQuery();
connection.Close();
It is part of the Microsoft Application Blocks framework.