I am trying to add some code to below to include a datatable and fill the
datatable. The reason for doing this is so as I can check to see whether
there are any rows returned by the stored procedure. If there are no records
returned then this would give me an indicator and I can re-direct the page
somewhere more appropriate. Well this is the theory. I have never used
datatables before and am not sure how to implemenet what I want so I was
wondering if someone could help me please. I basically just need a datatable
and then fill the datatable with my record set. Thanks for any help anyone
can give me.
private static SqlDataReader dr;
private void PPS4_ReportStar t(object sender, System.EventArg s eArgs)
{
//Create a Connection
SqlConnection conSQL = new
SqlConnection(C onfigurationSet tings.AppSettin gs["DBConnectionSt ring"]);
//Create Parameter
SqlParameter @IPCURN = new SqlParameter
("@IPCURN", System.Data.Sql DbType.BigInt);
@IPCURN.Directi on = ParameterDirect ion.Input;
@IPCURN.Value = IPC;
//Create Parameter
SqlParameter @SUSPECTURN = new SqlParameter
("@SUSPECTUR N", System.Data.Sql DbType.BigInt);
@SUSPECTURN.Dir ection = ParameterDirect ion.Input;
@SUSPECTURN.Val ue = SUSPECT;
//Create a Command
SqlDataAdapter da = new SqlDataAdapter( );
//DataTable dt = new DataTable();
da.SelectComman d = new SqlCommand();
da.SelectComman d.Connection = conSQL;
da.SelectComman d.CommandText = "rep_PersonChar gedInCustody_PP S4 ";
da.SelectComman d.CommandType = CommandType.Sto redProcedure;
da.SelectComman d.Parameters.Ad d(@IPCURN);
da.SelectComman d.Parameters.Ad d(@SUSPECTURN);
conSQL.Open();
//Create a datareader
dr = da.SelectComman d.ExecuteReader ();
}
datatable. The reason for doing this is so as I can check to see whether
there are any rows returned by the stored procedure. If there are no records
returned then this would give me an indicator and I can re-direct the page
somewhere more appropriate. Well this is the theory. I have never used
datatables before and am not sure how to implemenet what I want so I was
wondering if someone could help me please. I basically just need a datatable
and then fill the datatable with my record set. Thanks for any help anyone
can give me.
private static SqlDataReader dr;
private void PPS4_ReportStar t(object sender, System.EventArg s eArgs)
{
//Create a Connection
SqlConnection conSQL = new
SqlConnection(C onfigurationSet tings.AppSettin gs["DBConnectionSt ring"]);
//Create Parameter
SqlParameter @IPCURN = new SqlParameter
("@IPCURN", System.Data.Sql DbType.BigInt);
@IPCURN.Directi on = ParameterDirect ion.Input;
@IPCURN.Value = IPC;
//Create Parameter
SqlParameter @SUSPECTURN = new SqlParameter
("@SUSPECTUR N", System.Data.Sql DbType.BigInt);
@SUSPECTURN.Dir ection = ParameterDirect ion.Input;
@SUSPECTURN.Val ue = SUSPECT;
//Create a Command
SqlDataAdapter da = new SqlDataAdapter( );
//DataTable dt = new DataTable();
da.SelectComman d = new SqlCommand();
da.SelectComman d.Connection = conSQL;
da.SelectComman d.CommandText = "rep_PersonChar gedInCustody_PP S4 ";
da.SelectComman d.CommandType = CommandType.Sto redProcedure;
da.SelectComman d.Parameters.Ad d(@IPCURN);
da.SelectComman d.Parameters.Ad d(@SUSPECTURN);
conSQL.Open();
//Create a datareader
dr = da.SelectComman d.ExecuteReader ();
}
Comment