Friday, March 6, 2009

Return datatable from Data logic layer in .net C#

One of my frenz asked how to return a datatable today
so i sent a code for him

posting the same here

public DataTable functionname()
{

DataTable dt = new DataTable();

DataSet ds = new DataSet();


ds = sqlhelper.ExecuteDataSet(strconnectionstring,CommandType.StoredProcedure,"Procdedurename",Param);

if (ds.Tables.count > 0 && ds.Tables[0].Rows.Count > 0)
{
dt = ds.Tables[0];
}


return dt;
}

No comments:

Post a Comment