verificar datos con c#
Publicado por arcenett (45 intervenciones) el 15/02/2007 21:48:53
hola a todos, tengo la siguiente duda como puedo verificar que el resultado de la siguiente consulta no venga en null??, esto esta hecho con C#, de antemano gracias ...jejej
hice un engendro de pregunta para poder saber eso pero no me funciona...
protected void Button1_Click(object sender, EventArgs e)
{
string texto1 ;
string texto2 ;
texto1 = TextBox1.Text;
texto2 = TextBox2.Text;
SqlConnection SqlConn = new SqlConnection("server=*******;uid=******;pwd=******;database=******");
SqlCommand SqlCom = new SqlCommand("select * from portal_usuarios where nombre='" + texto1 + "'and contraseña='" + texto2 + "'", SqlConn);
SqlConn.Open();
SqlDataReader myReader = SqlCom.ExecuteReader();
string readerx;
while (myReader.Read())
{
readerx = myReader.GetValue(2).ToString();
if (readerx != "null")
{
Response.Write(readerx);
}
else
{ Response.Write("no tengo datos"); }
}
SqlConn.Close();
}
hice un engendro de pregunta para poder saber eso pero no me funciona...
protected void Button1_Click(object sender, EventArgs e)
{
string texto1 ;
string texto2 ;
texto1 = TextBox1.Text;
texto2 = TextBox2.Text;
SqlConnection SqlConn = new SqlConnection("server=*******;uid=******;pwd=******;database=******");
SqlCommand SqlCom = new SqlCommand("select * from portal_usuarios where nombre='" + texto1 + "'and contraseña='" + texto2 + "'", SqlConn);
SqlConn.Open();
SqlDataReader myReader = SqlCom.ExecuteReader();
string readerx;
while (myReader.Read())
{
readerx = myReader.GetValue(2).ToString();
if (readerx != "null")
{
Response.Write(readerx);
}
else
{ Response.Write("no tengo datos"); }
}
SqlConn.Close();
}
Valora esta pregunta


0