0
データを追加したいが、2つのDataGridViewに入れたい。私はこれを試してみましたが、私は仕事を文句を言わない第二のDataGridViewで、それは文句を言わないだけ第一のDataGridViewで、追加2つのDatagridviewにデータを追加する
string query = "insert into dbuser.patientform (patientname,homeaddress,occupation,emailaddress,sex,age,status,birthday,cellphoneno,refferedby,date,diagnosis,treatment)"
+ "values('" + this.textBox1.Text + "','" + this.textBox2.Text + "','" + this.textBox3.Text + "','" + this.textBox4.Text + "','" + this.comboBox1.SelectedItem + "','" + this.textBox5.Text + "','" + this.comboBox2.SelectedItem + "','" + this.dateTimePicker1.Text + "','" + this.textBox6.Text + "','" + this.textBox7.Text + "','" + this.dateTimePicker2.Text + "','" + this.textBox8.Text + "','" + this.textBox9.Text + "') ;";
string quer = "insert into dbuser.patienthistory (patientname,date,diagnosis,treatment)"
+ "values('" + this.textBox1.Text + this.dateTimePicker2.Text + "','" + this.textBox8.Text + "','" + this.textBox9.Text + "') ;";
MySqlCommand cmd = new MySqlCommand(query, condb);
MySqlCommand cm = new MySqlCommand(quer, condb);
MySqlDataReader myreader;
MySqlDataReader myreader1;
try
{
condb.Open();
myreader = cmd.ExecuteReader();
condb.Close();
condb.Open();
myreader1 = cm.ExecuteReader();
MessageBox.Show("Saved");
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
comboBox1.SelectedItem = false;
textBox5.Clear();
comboBox2.SelectedItem = false;
textBox6.Clear();
textBox7.Clear();
textBox8.Clear();
textBox9.Clear();
dateTimePicker1.Text = null;
condb.Close();
dataset = new DataTable();
da.Fill(dataset);
BindingSource bs = new BindingSource();
bs.DataSource = dataset;
dataGridView1.DataSource = bs;
dataGridView2.DataSource = bs;
da.Update(dataset);
へ
セットのDataTable? –