Estoy intentando mostrar en un label el contenido de la base de datos pero me da el siguiente error en el datareader (this.Label1.Text =
dr("Noticias") ;) todo está creado en c#.
Muchas gracias.
Error1: '_Default.dr' es 'campo' pero se utiliza como 'método'
mi código es el siguiente:
Código PHP:
public partial class _Default : System.Web.UI.Page
{
private SqlConnection con;
private SqlCommand cmd;
private SqlDataReader dr;
protected void Page_Load(object sender, EventArgs e)
{
con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
con.Open();
cmd.Connection = con;
cmd.CommandText = "select id, noticias from Noticias";
dr = cmd.ExecuteReader();
while (dr.Read())
{
this.Label1.Text = dr("Noticias") ;
}
dr.Close();
con.Close();
}
}