title: OleDb Exception in c# “No value given for one or more required parameters.” while trying to Select Data from Access database
body: <p>I have the following code:</p>
  
  <pre><code> public DataTable opencon(PAL.property objpal)
      {
          string query = "Select UserId,Firstname,UserType from TBL_USER_LOGIN where Username=@username and Password=@password and Status=1";
          OleDbCommand objcmd = new OleDbCommand();
          objcmd.CommandText = query;
          objcmd.Connection = oldbcon;
          oldbcon.Open();
          objcmd.Parameters.Add("@username", OleDbType.VarChar).Value = objpal.username;
          objcmd.Parameters.Add("@password", OleDbType.VarChar).Value = objpal.Password;
          DataTable dt = new DataTable();
          OleDbDataAdapter adp = new OleDbDataAdapter(objcmd);
          adp.Fill(dt);
          return dt;
      }
  </code></pre>
  
  <p>Here I want to fetch some values from the table according to a condition,
  but when I run this code it shows the following error:
  <img src="https://i.stack.imgur.com/uS0kA.png" alt="enter image description here"></p>
  
  <p>Even though I passed the correct parameters value in @username and @password.  How can I resolve this error?  Please help.</p>