i hve reservation form
add function and add button
public void addreserve()
{
string constring = @"Data Source=.\SQLEXPRESS;Database=htm;Integrated Security=True";
SqlConnection con = new SqlConnection(constring);
con.Open();
DataTable dt = new DataTable();
SqlCommand com = new SqlCommand("insertreserveinfo", con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.Add(new SqlParameter("@Reservation_id", myreserv.Reservation_ID1));
com.Parameters.Add(new SqlParameter("@Guest_id", myreserv.Guest_name));
com.Parameters.Add(new SqlParameter("@Room_ID", myreserv.Room_no));
com.Parameters.Add(new SqlParameter("@Service_ID", myreserv.Service));
com.Parameters.Add(new SqlParameter("@No_of_days", myreserv.No_of_days));
com.Parameters.Add(new SqlParameter("@Check_in", myreserv.Check_in));
com.Parameters.Add(new SqlParameter("@Check_out", myreserv.Check_out));
com.ExecuteNonQuery();
con.Close();
}
add button
private void add_Click_2(object sender, EventArgs e)
{
try
{
Reservation_manager manage = new Reservation_manager(info);
info.Reservation_ID1 = Convert.ToInt32(txt_reser.Text);
Guest_info mygst = new Guest_info();
info.Guest_name = text_guest.SelectedValue.ToString();
Room myrm = new Room();
info.Room_no = Convert.ToInt32(txt_room.Text);
info.Service = txt_servce.SelectedValue.ToString();
info.No_of_days = Convert.ToInt32(txt_days.Text);
info.Check_in = Convert.ToDateTime(check_in.Text);
info.Check_out = Convert.ToDateTime(check_out.Text);
manage.addreserve();
dataGridView1.DataSource = info.GetRecords();
MessageBox.Show("Reservation Added Successfully!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
dt.Clear();
dt = info.GetRecords();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
but when i add data then the error show that
Input string is not in correct format???
whr is the problem
and ID is auto generated