C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

About SqlHelper Class


Posted Date: 03 Jul 2007    Resource Type: Articles    Category: .NET Framework
Author: Saravana Kumar.NMember Level: Gold    
Rating: 1 out of 5Points: 10



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.

Example

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

}



Summary



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











Responses

Author: Madhu    06 Jul 2007Member Level: Bronze   Points : 0
Use ful article


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: woooooow c# is this much simple....... ?
Previous Resource: Advanced Features of C# structure datatype
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use