title: c# too many arguments specified in a procedure or a function
body: <p>I wrote a stored procedure to check whether the username and password exists in the database and return the results accordingly</p>
  
  <p>This is the stored procedure</p>
  
  <pre><code> ALTER proc [dbo].[checkuser]
   @userid varchar(20),
   @password varchar(20),
   @ReturnVal varchar(50) output
   As 
   Begin
   if exists(select userid from users where userid=@userid)
   set @ReturnVal='Logged in Successfully'
   else
   set @ReturnVal='Login Failed'
   end
  </code></pre>
  
  <p>and this is my c# code</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      OleDbConnection conn = new OleDbConnection(
        "File Name=E:\\Vivek\\License Manager\\License Manager\\login.udl");
  
      try
      {  
          conn.Open();               
          OleDbCommand cmd = new OleDbCommand("checkuser",conn);              
          cmd.CommandType = CommandType.StoredProcedure;                
          OleDbParameter p1=new OleDbParameter("userid",username.Text); 
          OleDbParameter p2 = new OleDbParameter("password",password.Text);
          cmd.Parameters.Add(p1);                
          cmd.Parameters.Add(p2);                
          var returnParameter = cmd.Parameters.Add("ReturnVal",OleDbType.Integer);
          returnParameter.Direction = ParameterDirection.ReturnValue;
          cmd.ExecuteNonQuery();
      }
      catch (Exception ex)
      {
          MessageBox.Show(ex.Message);
  
      }
  }
  </code></pre>
  
  <p>I am new to c#.I want to check whether the username exists from the database.But when I execute the code I get an error saying "too many arguments specified in a procedure or a function ".</p>
  
  <p>Can anyone tell me where am I making a mistake?</p>
  
  <p>Thanks </p>