markyjj01
Programmer
- Feb 10, 2008
- 5
Can someone please help me with the following I am getting a mappings exception as follows: 'Update unable to find TableMapping['MovTable1'] or DataTable 'MovTable1'.
This happens when I try to save the changes made when I have entered details
onto a datagrid which is linked to a sql database. The dataset I create is
called Movset1 and I fill this with the table from sql called MovTable1. But
when I use the following ' F1.MovAdapt.Update(F1.Movset1, "MovTable1")' this
cuases the TableMapping exception.
the updated C# code I am now using is below....thanks for any help
//code when loading data grid//
private void button3_Click(object sender, System.EventArgs e)
{ Form3 F3 = new Form3();
SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(MovAdapt);
MovAdapt.TableMappings.Add("MovMapping", "MovTable1");
Mcon.Open();
Movcmd.CommandText = "SELECT * FROM MovTable1";
MovAdapt.SelectCommand = Movcmd;
MovAdapt.Fill(Movset1, "MovTable1");
F3.dataGrid1.DataSource = Movset1;
F3.Show();
}
-----------------------------
//code behind the save button//
private void button1_Click(object sender, System.EventArgs e)
{
F1.MovAdapt.Update(F1.Movset1, "MovTable1");
Form1.Mcon.Close();
}
This happens when I try to save the changes made when I have entered details
onto a datagrid which is linked to a sql database. The dataset I create is
called Movset1 and I fill this with the table from sql called MovTable1. But
when I use the following ' F1.MovAdapt.Update(F1.Movset1, "MovTable1")' this
cuases the TableMapping exception.
the updated C# code I am now using is below....thanks for any help
//code when loading data grid//
private void button3_Click(object sender, System.EventArgs e)
{ Form3 F3 = new Form3();
SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(MovAdapt);
MovAdapt.TableMappings.Add("MovMapping", "MovTable1");
Mcon.Open();
Movcmd.CommandText = "SELECT * FROM MovTable1";
MovAdapt.SelectCommand = Movcmd;
MovAdapt.Fill(Movset1, "MovTable1");
F3.dataGrid1.DataSource = Movset1;
F3.Show();
}
-----------------------------
//code behind the save button//
private void button1_Click(object sender, System.EventArgs e)
{
F1.MovAdapt.Update(F1.Movset1, "MovTable1");
Form1.Mcon.Close();
}