/// Execute the stored procedure with parameters and return the data set
/// </Summary>
/// <Param name = "procname"> stored procedure name </param>
/// <Param name = "Parameters"> sqlparametercollection input parameters </param>
/// <Returns> </returns>
Public static datatable (string procname, sqlparametercollection parameters)
{
Sqldataadapter da = new sqldataadapter ();
Datatable = new datatable ();
Try
{
Openconnection ();
Comm. Parameters. Clear ();
Comm. commandtype = commandtype. storedprocedure;
Comm. commandtext = procname;
Foreach (sqlparameter para in parameters)
{
Sqlparameter P = (sqlparameter) para;
Comm. Parameters. Add (P );
}
Da. selectcommand = comm;
Da. Fill (datatable );
}
Catch (exception E)
{
Throw new exception (E. Message );
}
Finally
{
Closeconnection ();
}
Return datatable;
}
Public static dataview (string sqlstr)
{
Sqldataadapter da = new sqldataadapter ();
Dataview DV = new dataview ();
Dataset DS = new dataset ();
Try
{
Openconnection ();
Comm. commandtype = commandtype. text;
Comm. commandtext = sqlstr;
Da. selectcommand = comm;
Da. Fill (DS );
DV = Ds. Tables [0]. defaultview;
}
Catch (exception E)
{
Throw new exception (E. Message );
}
Finally
{
Closeconnection ();
}
Return DV;
}
}
}