Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UNABLE TO UPDATE SQL SERVER EXPRESS DATBASE

Status
Not open for further replies.

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 is better asked in the C# forum, but my guess is that your table mapping values may be mixed up. Are the values in
MovAdapt.TableMappings.Add("MovMapping", "MovTable1");
in the correct order for the function?

Once again, if I were you I would post to the relevant forum. Nothing in SQL Server relates to what you're doing in your code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top