when my dTable depends
on user choice. I have one Dataset with several tables, and name of the chosen
Table apears in Label1.Text.
How to save changes from
dataGridView to Database? The problem is that bindigSource.DataMember is known only in runtime, when user select the Table Name.
I have tried following code:
C#
Normal
0falsefalsefalse
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}privatevoidsaveToolStripButton_Click(object sender, EventArgs e)
{
OleDbDataAdapter da = new OleDbDataAdapter();
BindingSource bindingSource1 = new BindingSource();
bindingSource1.DataMember = label1.Text;
bindingSource1.DataSource = dataGridView1.DataSource;
this.Validate();
this.bindingSource1.DataSource = ds;
this.bindingSource1.DataMember = label1.Text;
DataTable dt = bindingSource1.DataSource as DataTable;
this.bindingSource1.EndEdit();
if (dt != null)
{
this.tableAdapterManager.UpdateAll(ds);
}
}
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
jingeRank #2,527 · 554 reputationPosted Nov 19, 2009, 2:35 PM EST
Miodrag Grahovac31 reputationPosted Nov 19, 2009, 9:35 PM EST