|
Note that the managerDataSet and jYDJLTableAdapter are generated after the system performs data binding, so there is no need to manually give the insertcommand. In the breakpoint, I can find that the managerDataSet has successfully added new rows, but the tableadapter does not use the new rows. The insert method is added to the database. Why is this so?
DataRow itemrow = managerDataSet.JYDJL.NewRow ();
itemrow ["Transaction time"] = dateTimePicker1.Value;
itemrow ["Transaction Type"] = comboBox1.Text.ToString (). Trim ();
itemrow ["Transaction Kind"] = comboBox2.Text.ToString (). Trim ();
itemrow ["Game"] = comboBox3.Text.ToString (). Trim ();
itemrow ["District service"] = textBox4.Text.ToString (). Trim ();
itemrow ["Account"] = textBox5.Text.ToString (). Trim ();
itemrow ["PIN"] = textBox6.Text.ToString (). Trim ();
itemrow ["Person Name"] = textBox7.Text.ToString (). Trim ();
itemrow ["Payment Method"] = comboBox4.Text.ToString (). Trim ();
itemrow ["Transaction Amount"] = d;
itemrow ["Payment Status"] = comboBox5.Text.ToString (). Trim ();
itemrow ["generation status"] = comboBox6.Text.ToString (). Trim ();
itemrow ["Trader"] = textBox9.Text.ToString (). Trim ();
itemrow ["Trading Platform"] = comboBox7.Text.ToString (). Trim ();
itemrow ["Communication Software"] = comboBox8.Text.ToString (). Trim ();
itemrow ["Communication Software ID"] = textBox10.Text.ToString (). Trim ();
itemrow ["Phone"] = textBox11.Text.ToString (). Trim ();
if (textBox12.Text.Trim ()! = "")
{
itemrow ["Task Time"] = dateTimePicker2.Value;
}
if (textBox13.Text.Trim ()! = "")
{
itemrow ["Completion time"] = dateTimePicker3.Value;
}
itemrow ["Detailed Description"] = richTextBox1.Text.ToString (). Trim ();
managerDataSet.JYDJL.Rows.Add (itemrow);
jYDJLBindingSource.EndEdit ();
try
{
jYDJLTableAdapter.Update (managerDataSet.JYDJL);
}
catch (Exception ex)
{
MessageBox.Show ("Add failed! Reason for failure:" + ex.Message, "Hint", MessageBoxButtons.OK, MessageBoxIcon.Error);
} |
|