title: C# is returning exception: Procedure has no parameters and arguments were supplied
body: <p>I apologise for this formatting. I am new to programming and new to this site, so I will try and make the question as clear as possible.</p>
  
  <p>I have a webform for accessing/modifying a Customer database. I have a button for entering new customers details which will automatically assign an ID number by getting the highest ID number from the database, and incrementing by one (and posting to form textbox).</p>
  
  <p>This is the code I have written:</p>
  
  <pre><code>protected void btnNew_Click(object sender, EventArgs e)
  {
          Clear();
  
          command.Connection = conn;
          command.CommandType = CommandType.StoredProcedure;
          command.CommandText = "NewCustomer";
  
          conn.Open();
  
          SqlParameter maxid = new SqlParameter();
          maxid.ParameterName = "@MaxID";
          maxid.SqlDbType = SqlDbType.Int;
          maxid.Direction = ParameterDirection.Output;
          command.Parameters.Add(maxid);
  
          command.ExecuteNonQuery();                       
  
          NewCustId = Convert.ToInt32(maxid.Value);
          NewCustId += 1;
  
          txtCustID.Text = (NewCustId).ToString();
          txtCustID.DataBind();
  
          conn.Close();
  }
  </code></pre>
  
  <p>This is the stored procedure:</p>
  
  <pre><code>CREATE PROCEDURE NewCustomer
      (@MaxID INT OUTPUT)
  AS
  BEGIN
      SELECT @MaxID = MAX(CustID)
      FROM dbo.Customer
  END
  </code></pre>
  
  <p>I have tried many different ways of coding it, but nothing seems to work.
  The code I have posted has an exception at <code>ExecuteNonQuery</code> saying arguments were supplied and procedure has no parameters. When I place <code>command.Parameters.Add(maxid);</code> underneath <code>ExecuteNonQuery</code>, it returns a 1.</p>
  
  <p>I ran the SQL Query alone to see what would happen and it returns a correct answer in an unnamed cell. For some reason the Column Name disappears when it comes up. Then when I try to use the C# code to access the unnamed cell, I can't seem to access it because the column 'CustID' "doesn't exist".</p>
  
  <p>With this code, I know that the SQL command is executing, and then the C# code increments by 1, but it seems that the return value I am getting is 0.</p>
  
  <p>I appreciated any ideas that I can get on how to fix this. Thank you.</p>
  
  <p>Edit: I have also tried:
            DataTable table = new DataTable();
            adapter.Fill(table);
            NewCustId = table.Rows[0].Field("CustID");</p>
  
  <p>(This is where it said 'CustID' column didn't exist)</p>