C# .NET - sql helper class usage

Asked By mithra on 25-Jan-11 05:18 AM
hi


where can download sql helper class and how to use the class in our program
Vivek Jagga replied to mithra on 25-Jan-11 05:25 AM
Introduction
  
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
  
Syntax
SqlHelper.ExecuteDataSet(SqlConnection connection,string spname,params object[] parameter)
  
We need a connection string,a sql query string and the values for the parameters.

try
{
        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 );

      }
Vivek Jagga replied to mithra on 25-Jan-11 05:26 AM
download SQL Helper class on http://www.microsoft.com/downloads/en/details.aspx?FamilyID=f63d1f0a-9877-4a7b-88ec-0426b48df275&displaylang=en
mithra replied to Vivek Jagga on 25-Jan-11 05:28 AM
hi


thanks for ur repy . but i exactly want to know how to add the dll files of sql helper class to our solution where to add those dll files. iam new to programing so i dont know much abt dll file usage
Vivek Jagga replied to mithra on 25-Jan-11 05:32 AM
1- Download DataAccessApplicationBlock.msi from http://www.microsoft.com/downloads/en/details.aspx?FamilyID=f63d1f0a-9877-4a7b-88ec-0426b48df275&displaylang=en
2- Open in Visual Studio.
3- Build Application in release mode.
4- Copy the dll from bin folder (Microsoft.ApplicationBlocks).
5- Add this dll reference in your application.
6- Include name space (Using Microsoft.ApplicationBlocks.Data);
and do your operation.
mithra replied to Vivek Jagga on 25-Jan-11 05:47 AM
should i put those dll files in my bin folder
Vivek Jagga replied to mithra on 25-Jan-11 05:56 AM
Yes.
mithra replied to Vivek Jagga on 25-Jan-11 06:19 AM
thanks for ur answer