none
how to insert the textbox to two databases with one textbox which has the similar data? RRS feed

  • Pertanyaan

  • how to insert the textbox to two databases with one textbox which has the similar data with the name of the data thas is txtcode if use the following code?
      	    int unit;
                string cmbunit2 = cmbunit.Text;
                int.TryParse(cmbunit2, out unit);
                MySqlConnection Connection2 = new MySqlConnection(MyConnection);
                MySqlCommand cmd;
                Connection2.Open();
                try
                {
                    cmd = Connection2.CreateCommand();
    
                    cmd.CommandText = "INSERT INTO data_barang(code1,name,short_name,category,unit) VALUES (@code1,@name,@short_name,@category,@unit)";
                    cmd.Parameters.AddWithValue("@code1", txcode.Text);
                    cmd.Parameters.AddWithValue("@name", txtname.Text);
                    cmd.Parameters.AddWithValue("@short_name", txtshort_name.Text);
                    cmd.Parameters.AddWithValue("@category", cmbcategory.Text);
                    cmd.Parameters.AddWithValue("@unit", cmbunit.Text);
                    cmd.ExecuteNonQuery();
                }



    Minggu, 22 November 2015 12.39

Jawaban

Semua Balasan