samedi 11 juin 2016

Error converting data type varchar to float. C# VS

I have the following SQL statement which is giving me this error.

THIS IS NOT MY CODE!

"Error converting data type varchar to float" But i can't find the error. I thnk the error is coming from this code:

        birthday = (monthComboBox.SelectedItem) + "-" + (dayComboBox.SelectedIndex + 1) + "-" + yearTextBox.Text;

        Int32 getIDBack = 0;

        string query = "insert into reservation(first_name, last_name, birth_day, gender, phone_number, email_address, number_guest, street_address, apt_suite,city, state, zip_code, room_type, room_floor, room_number, total_bill,payment_type, card_type, card_number,card_exp,card_cvc, arrival_time, leaving_time, check_in, break_fast, lunch, dinner, supply_status, cleaning, towel, s_surprise, food_bill) values('" + firstNameTextBox.Text +

            "', '" + lastNameTextBox.Text + "', '" + birthday + "', '" + genderComboBox.SelectedItem + "', '" + phoneNumberTextBox.Text + "', '" + emailTextBox.Text +

          "', '" + (qtGuestComboBox.SelectedIndex + 1) + "', '" + addLabel.Text + "', '" + aptTextBox.Text + "', '" + cityTextBox.Text +

          "', , '" + zipComboBox.Text + "', '" + roomTypeComboBox.SelectedItem + "', '" + floorComboBox.SelectedItem +

          "', '" + roomNComboBox.SelectedItem + "', '" + finalizedTotalAmount + "', '" + paymentType +

          "', '" + CardType + "','" + paymentCardNumber + "','" + MM_YY_Of_Card + "','" + CVC_Of_Card + "', '" + dateTimePicker1.Text + "', '" + dateTimePicker2.Text + "','" + checkin +

          "', '" + breakfast + "','" + lunch + "','" + dinner + "', '" + foodStatus + "', '" + Convert.ToInt32(cleaning) + "', '" + Convert.ToInt32(towel) + "', '" + Convert.ToInt32(surprise) + "','" + foodBill + "');";
        query += "SELECT CAST(scope_identity() AS int)";
        SqlConnection connection = new SqlConnection(Hotel_Manager.Properties.Settings.Default.frontend_reservationConnectionString);

        SqlCommand query_table = new SqlCommand(query, connection);
        try
        {
            connection.Open();
            getIDBack = (Int32)query_table.ExecuteScalar();

            string userID = Convert.ToString(getIDBack);
            SendSMS(getIDBack);
            MetroFramework.MetroMessageBox.Show(this, "Entry successfully inserted into database. " + "nn" +
                "Provide this unique ID to the customer." + "nn" +
            "USER UNIQUE ID: " + userID, "Report", MessageBoxButtons.OK, MessageBoxIcon.Question);

            connection.Close();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

        ComboBoxItemsFromDataBase();
        LoadForDataGridView();
        reset_frontend();
        GetOccupiedRoom();
        ReservedRoom();
        getChecked();
    }

Aucun commentaire:

Enregistrer un commentaire