.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> ADO.NET >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Data Access Layer-- PART-3

Posted By:BangaruBabuPureti       Posted Date: May 13, 2010    Points: 10    Category: ADO.NET    URL: http://www.dotnetspark.com  

Hi I Developed Data Access Layer(DAL) By Utilizing SQL-Helper Class.It is Easy To Write and Organize Business Access Layer(BAL) very effectively.I am Going To Post This DAL in Three PARTS--This Is PART-3 of the Series
 

public static SqlDataReader ExecuteSPDataReader(string strSPName, params  
SqlParameter[] objParams)
{
    SqlDataReader reader;
    try
    {
        reader = SqlHelper.ExecuteReader(getConnection(),  
CommandType.StoredProcedure, strSPName, objParams);
    }
    catch (SqlException exception)
    {
        throw exception;
    }
    catch (Exception exception2)
    {
        throw exception2;
    }
    return reader;
}

 
-----------------

public static DataSet ExecuteSPDataset(string strSPName, params  
SqlParameter[] objParams)
{
    DataSet set;
    try
    {
        set = SqlHelper.ExecuteDataset(getConnection(),  
CommandType.StoredProcedure, strSPName, objParams);
    }
    catch (SqlException exception)
    {
        throw exception;
    }
    catch (Exception exception2)
    {
        throw exception2;
    }
    return set;
}
-----------
public static int ExecuteSPNonQuery(string strSPName, params SqlParameter[] objparams)
{
    int num;
    try
    {
        num = SqlHelper.ExecuteNonQuery(getConnection(),  
CommandType.StoredProcedure, strSPName, objparams);
    }
    catch (SqlException exception)
    {
        throw exception;
    }
    catch (Exception exception2)
    {
        throw exception2;
    }
    return num;
}

----------
public static int ExecuteSPNonQuery(SqlTransaction transaction, string  
strSPName, params SqlParameter[] objparams)
{
    int num;
    try
    {
        num = SqlHelper.ExecuteNonQuery(transaction,  
CommandType.StoredProcedure, strSPName, objparams);
    }
    catch (SqlException exception)
    {
        throw exception;
    }
    catch (Exception exception2)
    {
        throw exception2;
    }
    return num;
}
--------------

public static object ExecuteSPScalar(string strSPName, params SqlParameter[]  
objparams)
{
    object obj2;
    try
    {
        obj2 = SqlHelper.ExecuteScalar(getConnection(), strSPName,  
objparams);
    }
    catch (SqlException exception)
    {
        throw exception;
    }
    catch (Exception exception2)
    {
        throw exception2;
    }
    return obj2;
}

------------------
public static SqlParameter[] GetCachedParameterSet(string commandText)
{
    return SqlHelperParameterCache.GetCachedParameterSet(getConnection(),  
commandText);
}

 -------------
public static string getConnection()
{
    return ConfigurationSettings.AppSettings["strCon"];
}

 -----------
public static SqlParameter[] GetSpParameterSet(string strSPName)
{
    return SqlHelperParameterCache.GetSpParameterSet(getConnection(),  
strSPName);
}

 ------------
public static SqlParameter[] GetSpParameterSet(string strSPName, bool  
includeReturnValueParameter)
{
    return SqlHelperParameterCache.GetSpParameterSet(getConnection(),  
strSPName, includeReturnValueParameter);
}


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend