lundi 3 octobre 2016

c# how to update checkbox in database through SQL Query

i am trying to update the checked state of a collom in my database.

below is the code i have but i am unsure of how to implement the checkbox. Thank you for any help.

                con.Open();
                OleDbCommand cmd = new OleDbCommand(String.Concat("Select * From ", comboBox1.Text), con);
                cmd.CommandType = CommandType.Text;
                string tableName = comboBox1.Text.ToString();
                cmd.CommandText = "UPDATE [" + tableName + "] SET People_Call_Status = '" + Status_textBox1.Text 
                    + "', Research_Date = '" + Date_textBox.Text
                    + "', Company_Name = '" + company_NameTextBox.Text
                    + "', tblCompanies_Area_Dialling_Code = '" + tblCompanies_Area_Dialling_CodeTextBox.Text
                    + "', Work_Number = '" + work_NumberTextBox.Text
                    + "', building_Address = '" + building_AddressTextBox.Text
                    + "', [Street Address] = '" + street_AddressTextBox.Text
                    + "', suburb = '" + suburbTextBox.Text
                    + "', city = '" + cityTextBox.Text
                    + "', res_Code = '" + res_CodeTextBox.Text
                    + "', industry_Vertical_ID = '" + industry_Vertical_IDTextBox.Text
                    + "', pO_Box = '" + pO_BoxTextBox.Text
                    + "', post_Office = '" + post_OfficeTextBox.Text
                    + "', postal_Code = '" + postal_CodeTextBox.Text
                    + "', country_ID = '" + country_IDTextBox.Text
                    + "', province_ID = '" + province_IDTextBox.Text
                    + "', prospect = '" + prospectCheckBox.Checked //not working

                    + "'  WHERE Company_ID = " + company_IDTextBox.Text + ";";




                cmd.ExecuteNonQuery();
                {
                    MessageBox.Show("Update Success!");
                    con.Close();
                }




Aucun commentaire:

Enregistrer un commentaire