I encounter a problem. I have a generic function that executes stored procedures via connection to my sql DB. In all SP I need only one dataTable to be returned.
public DataTable ExecuteStoredProcedure(string SpName, bool byStoredProce, string[] Searchparam, DataTable dt)
{
oDataTable = null;
oex = null;
try
{
oDataTable = new DataTable(Convert.ToString(globalParm.cntDataTable));
objCmd = new SqlCommand(SpName.ToString(), oConn);
objCmd.CommandType = CommandType.StoredProcedure;
if (!byStoredProce)
{
objCmd.CommandType = CommandType.Text;
}
using (SqlCommand cmd = new SqlCommand(SpName.ToString(), oConn)) //
{
cmd.CommandType = CommandType.StoredProcedure;
fillData(SpName, ref Searchparam, cmd, dt);
da = new SqlDataAdapter(cmd);
da.Fill(oDataTable);
}
}
catch (SqlException ex)
{
}
return oDataTable;
}
I added a new sql SP that retrives 2 data tables. What the best modification for the function above to get any number of data tables ? When I run this new SP, oDataTable contains the first (between two) of the returned datatables.