SQL Query use Maintenance
INSERT INTO tbl_asigncharges (CHARGES, VALUEofCHARGES) select TYPEOFCHARGES,VALUEofCHARGES from tbl_charges
this table apply in to this query C# Code
try { foreach (var item in checkedListBox1.CheckedItems) { if (!checkedListBox2.Items.Contains(item.ToString())) { checkedListBox2.Items.Add(item); string i = (item.ToString()); if (MessageBox.Show("Assgned", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK) { sqlcon.Open(); string query = "INSERT INTO tbl_asigncharges (SN,CHARGES,VALUEofCHARGES) VALUES ('" + Convert.ToInt32(regno.Text) + "','" + item.ToString() + "','" + Convert.ToInt32(i) + "')"; SqlDataAdapter sda = new SqlDataAdapter(query, sqlcon); sda.SelectCommand.ExecuteNonQuery(); sqlcon.Close(); } } } } catch(Exception ex) { MessageBox.Show("Error" + ex); }
code try in C# windows Form application