Input string was not in a correct format
<p>I'm trying to make a simple application form were user can input data like <code>'reservationid', 'bookid', 'EmployeeID' and 'reservedate'</code>. Its from my program Library System. <code>'reservationid' is an auto increment primary key</code> while the rest are <code>BigInt50, NVarChar50 and DateTime10</code> respectively. So I'm having this error: <code>Input String was not in a correct format</code>. <code>It worked fine a while ago until I modified the 'reservationid' to auto increment</code> so where did I go wrong? I've attached a sample of my code behind. </p>

<p>Any help would be greatly appreciated! Thanks in advance!</p>

<pre><code>namespace LibraryManagementSystemC4.User
{
    public partial class Reserving : System.Web.UI.Page
    {
        public string GetConnectionString()
        {
            return System.Configuration.ConfigurationManager.ConnectionStrings["LibrarySystemConnectionString"].ConnectionString;
        }
        //string reservationid
        private void ExecuteInsert(string bookid, string EmployeeID, string reservedate)
        {
            SqlConnection conn = new SqlConnection(GetConnectionString());

            string sql = "INSERT INTO BookReservation (reservationid, bookid, EmployeeID, reservedate) VALUES " + " (@reservationid, @bookid, @EmployeeID, @reservedate)";
            try
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(sql, conn);
                SqlParameter[] param = new SqlParameter[3];

                //param[0] = new SqlParameter("@reeservationid", SqlDbType.Int, 50);
                param[0] = new SqlParameter("@bookid", SqlDbType.BigInt, 50);
                param[1] = new SqlParameter("@EmployeeID", SqlDbType.NVarChar, 50);
                param[2] = new SqlParameter("@reservedate", SqlDbType.DateTime, 10);

                //param[0].Value = reservationid;
                param[0].Value = bookid;
                param[1].Value = EmployeeID;
                param[2].Value = reservedate;

                for (int i = 0; i &lt; param.Length; i++)
                {
                    cmd.Parameters.Add(param[i]);
                }

                cmd.CommandType = CommandType.Text;
                cmd.ExecuteNonQuery();
            }

            catch (System.Data.SqlClient.SqlException ex)
            {
                string msg = "Insert error";
                msg += ex.Message;
                throw new Exception(msg);
            }

            finally
            {
                conn.Close();
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (reservationidTextBox != null)
            {
                //reservationidTextBox.Text
                ExecuteInsert(bookidTextBox.Text, EmployeeIDTextBox.Text, reservationidTextBox.Text);

                ClearControls(Page);
            }

            else
            {
                Response.Write("Please input ISBN");
                bookidTextBox.Focus();
            }

            {
                //get bookid from Book Details and Employee PIN from current logged-in user
                bookidTextBox.Text = DetailsView1.SelectedValue.ToString();
                EmployeeIDTextBox.Text = HttpContext.Current.User.Identity.ToString();
            }
        }

        public static void ClearControls(Control Parent)
        {
            if (Parent is TextBox)
            {
                (Parent as TextBox).Text = string.Empty;
            }

            else
            {
                foreach (Control c in Parent.Controls)
                    ClearControls(c);
            }
        }
    }
}
</code></pre>
