Search code examples
c#databaseoledb

how to match table value to a text box value using c#


This is code for select user password where id = 1 ; I want to match this value to a text box. If the value is a match then second window form will be open. But it is not working ...

OleDbConnection con = new OleDbConnection(database2.conn);
con.Open();
OleDbCommand OCom = new OleDbCommand("select user_pasword from tblpasword where id = 1", con);
OleDbDataReader Dreader = OCom.ExecuteReader();

while (Dreader.Read())
{
  MessageBox.Show(Dreader + "");
}

Solution

  • If I am not wrong I think you can use

    while(Dreader.Read())
    {
        if(Dreader["_password"].ToString()==txtbox.text)
        {
        objectofform.show()
        }
    }