I have a set aspx.cs codes to call a stored procedure to populate a grid view in my front end website. However during the run gridview is not populated but there are no errors. So I would like to know how to print the SQL query that was executed with the parameters as well. Thanks
The reason is being when I run with the existing data it populates however if new data are added it causes the gridview to be not populated at all.
using (SqlConnection conn = new SqlConnection(dbConn))
{
using (SqlCommand cmd = new SqlCommand(spretrieve, conn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@param1", SqlDbType.VarChar).Value = selectedDATE;
cmd.Parameters.Add("@param2", SqlDbType.VarChar).Value = selectedLVL2RISK;
cmd.Parameters.Add("@param3", SqlDbType.VarChar).Value = selectedORSA;
cmd.Parameters.Add("@param4", SqlDbType.VarChar).Value = selectedDPT;
string query = cmd.CommandText;
//Populate ORSA_ASSESSMENTS grid view
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GRID.DataSource = ds.Tables[0];
GRID.DataBind();
}
}