About SqlHelper Class

This article helps you to access the Sql Helper Class and example of code snippet for SqlHelper Class


We might know how to use ADO.Net concepts like SqlConnection,SqlDatAdapter and SqlCommand.But using this we want to write "n" no.of lines to connect with backend.To reduce these lines we are using SqlHelper Class.

Namespace for SqlHelper

SqlHelper Class comes from the namespace Microsoft.ApplicationBlocks.Data.This is a third tool party we should get from msdn and install and add the dll file to our project.

Methods in SqlHelper Class

  • ExecuteDataSet

  • ExecuteNonQuery

  • ExecuteReader

  • ExecuteScalar

  • ExecuteXmlReader

I think u know about these methods.The syntax to use these methods

SqlHelper.ExecuteDataSet(SqlConnection connection,string spname,params object[] parameter)

We need a connection string,a sql query string and the values for the parameters.


SqlHelper.ExecuteNonQuery(DataAccess.ConnectionString, CommandType.StoredProcedure, "empinsert", new SqlParameter ("@EmpNo",empno), new SqlParameter("@EmpName",ename),new SqlParameter ("@EmpSal",empsal));
} catch (Exception ee)
MessageBox.Show(ee.Message );



The usage of SqlHelper Class is to reduce the no.of.lines for connecting the database through SqlClient or Oledb


Author: Madhu06 Jul 2007 Member Level: Bronze   Points : 0

Use ful article

Guest Author: Sudarshan08 Oct 2012

Very useful article....

Guest Author: Sudheer P17 Feb 2013

Thank you very much. It is very useful and you explained very clearly.

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: