I had c# application that has registration form and another from that user use to sigin in into my application
i wonder how to check if user its register or not
my login form has to textbox username and passpwrd
and im trying this code i gusse its wrong can anyone help me to get through it ?
public void isUserExist()
{
try
{
string connstring = "data source=test_db;user id=system;password=password;";
string statementcmd = "SELECT * FROM register_user Where UserName=@username";
string username = "";
string password = "";
OracleConnection conn = new OracleConnection(connstring);
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = statementcmd;
cmd.Parameters.Add("@username", username);
if (conn.State != ConnectionState.Open)
{
conn.Open();
OracleDataReader reader = cmd.ExecuteReader();
if (!reader.HasRows)
{ MessageBox.Show("User Name Not Found"); }
if (!password.Equals(reader["password"].ToString()))
MessageBox.Show("Incorrect Password");
reader.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}