J
Jordi Maicas
Hello again!
I've got a typical problem validating a user/pass through an access database
with C#. I tried with two functions, and both tell me that the resulting
string is out of context.
How could I solve it?
Thanks.
Boolean comprueba_loguin(String usuario,String password)
{
String prueba,cadena;
OleDbConnection myConn = new
OleDbConnection(TabStripApp.Properties.Settings.Default.onlydentConnectionString);
OleDbCommand myComm = new OleDbCommand("select usuario,password from
usuarios", myConn);
myConn.Open();
OleDbDataReader myReader = myComm.ExecuteReader();
if (myReader.HasRows)
{
cadena = myReader.GetString(0);
myReader.Close();
return true;
}
else
{
myReader.Close();
return false;
}
}
Boolean comprueba_loguin2(String usuario, String password)
{
String prueba, cadena;
String sqlquery= "select usuario,password from usuarios";
String ConnectionString =
TabStripApp.Properties.Settings.Default.onlydentConnectionString;
OleDbConnection con = new OleDbConnection(ConnectionString);
OleDbCommand cmd = new OleDbCommand(sqlquery, con);
con.Open();
cmd.ExecuteNonQuery();
object resultquery = cmd.ExecuteReader();
string resultado = resultquery.ToString();
con.Close();
return true;
}
I've got a typical problem validating a user/pass through an access database
with C#. I tried with two functions, and both tell me that the resulting
string is out of context.
How could I solve it?
Thanks.
Boolean comprueba_loguin(String usuario,String password)
{
String prueba,cadena;
OleDbConnection myConn = new
OleDbConnection(TabStripApp.Properties.Settings.Default.onlydentConnectionString);
OleDbCommand myComm = new OleDbCommand("select usuario,password from
usuarios", myConn);
myConn.Open();
OleDbDataReader myReader = myComm.ExecuteReader();
if (myReader.HasRows)
{
cadena = myReader.GetString(0);
myReader.Close();
return true;
}
else
{
myReader.Close();
return false;
}
}
Boolean comprueba_loguin2(String usuario, String password)
{
String prueba, cadena;
String sqlquery= "select usuario,password from usuarios";
String ConnectionString =
TabStripApp.Properties.Settings.Default.onlydentConnectionString;
OleDbConnection con = new OleDbConnection(ConnectionString);
OleDbCommand cmd = new OleDbCommand(sqlquery, con);
con.Open();
cmd.ExecuteNonQuery();
object resultquery = cmd.ExecuteReader();
string resultado = resultquery.ToString();
con.Close();
return true;
}