Good day everyone. I have a sp SQL Server 2008 that throws me the following result:
Total_Registros
1
On the other hand, I have a form that contains a label (lbl_totals),
nbsp;
<asp:Label ID="lbl_totales" runat="server" Text=""></asp:Label>
which I would like you to show the result of this sp. The sp such as, throws me the result indicated above. I have this code which I am testing, however, it still does not show the result in my label. Does anyone know where my error is? Or could you give me some additional idea?
protected void TotalReg()
{
clsConexioncs cnx = new clsConexioncs();
try
{
DataSet ds;
cnx.Conexion = System.Configuration.ConfigurationManager.ConnectionStrings["DefaultPRM"].ToString();
cnx.PreparaComandoSP("prm_spTotalRegistrosNAV");
ds= cnx.EjecutaComandoDataSet();
foreach(DataRow dr in ds.Tables[0].Rows )
{
//lbl_totales.Text = dr[0].ToString();
lbl_totales.Text = dr["Total_Registros"].ToString();
}
}
catch (Exception ex)
{
MessageBox("Ha ocurrido el siguiente error " + ex.Message.ToString());
}
finally { cnx = null; }
}
Expected result would be the following:
Total_registros: [lbl_totales]
Where lbl_totals would be the label where it would show the result of the sp. Staying in the following way:
Total_registros: 0