Guest User

Guest User

  • Tech Writer
  • 529
  • 36.3k

1 table form any other table value set in String query ?

Jun 13 2021 10:19 PM

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


Answers (9)