Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/01/2009, 12:33
igonfil
 
Fecha de Ingreso: junio-2008
Mensajes: 250
Antigüedad: 16 años, 9 meses
Puntos: 1
error en la conexion a la base de datos

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 senderEventArgs 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();
}