HI,

i have the following code and i am getting the error

private Reservation getReservationDetails()
        {
            Customer c = GetCustomerDetails();
            ManagerCustomers mgrCustomer = new ManagerCustomers();
            int customerID = mgrCustomer.SearchCustomerByIDCardNumber(c.IDCardNumber);

            DateTime reservationAdded = DateTime.Now;
            
            int numberOfPeople = Convert.ToInt32(nudNumberOfPeople.Value.ToString());

            string dateOfEvent = dtpReservationDate.Value.ToLongDateString();
            string timeOfEvent = dtpEventTime.Value.ToLongTimeString();
            
            DateTime dateTimeOfEvent = Convert.ToDateTime(dateOfEvent + " " + timeOfEvent);
            
            int eventTypeID = Convert.ToInt32(cmbEventType.SelectedValue.ToString());
            
            bool done = Convert.ToBoolean(cbReservationComplete.Checked.ToString());

            bool cancelled = Convert.ToBoolean(cbCanceled.Checked.ToString());

            int staffSelected = selectedStaff(dateTimeOfEvent);

            int staffID = selectedStaff(dateTimeOfEvent);


            Reservation res = new Reservation(reservationAdded, numberOfPeople, dateTimeOfEvent, eventTypeID, done, customerID, staffID, cancelled);

            return res;
        }
public bool AddReservation(Reservation r)
        {
            bool reservationIdUnique = IsUnique(r);

            if (reservationIdUnique)
            {
                try
                {
                    conn.Open();

                    SqlCommand comm = new SqlCommand("INSERT INTO tblReservation VALUES ('" + r.DateTimeReservation.ToString("MM/dd/yyyy") + "','" + r.NumberOfPeople + "','" + r.DateTimeOfEvent.ToString("MM/dd/yyyy") + "','" + r.EventTypeID + "','" + r.Done + "','" + r.CustomerID + "','" + r.StaffID + "','" + r.Cancelled + "')", conn);

                    comm.ExecuteNonQuery();
                    return true;
                }

                catch (Exception e)
                {
                    MessageBox.Show(e.Message.ToString());
                    return false;
                }

                finally
                {
                    conn.Close();
                }
            }

            else
            {
                return false;
            }
        }

Your SQL is attempting to put the value 'False' (as in the string) into a tinyint (which is numeric) column. You need to check the boolean value and assign it to a 0 or a 1. You are converting it to a string by setting it the way that you are. Hint: A more efficient and accurate way to run SQL queries in C# is to use parameters.

Your SQL is attempting to put the value 'False' (as in the string) into a tinyint (which is numeric) column. You need to check the boolean value and assign it to a 0 or a 1. You are converting it to a string by setting it the way that you are. Hint: A more efficient and accurate way to run SQL queries in C# is to use parameters.

thx very much i resolved it ;) happy easter

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.