Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hi All,

I got this error when updating database from datatable.

{"Update unable to find TableMapping['Table'] or DataTable 'Table'."}

Here is my code (modified) :
C#
SqlCeDataAdapter da = new SqlCeDataAdapter("SELECT * FROM Name", con);
DataSet ds = new DataSet();
da.Fill(ds, "Name");
foreach (DataRow dr in ds.Tables["Name"].Rows)
{
    Console.WriteLine(dr["FirsName"] + "\t" + dr["NickName"] + "\t" + dr["Address"] + "\t" + dr["Gender"]);
    dr["Gender"]="Male";
}
da.Update(ds);
Console.Write("Press Enter to continue:");
Console.ReadLine();

Any Help??

Thanks
Posted
Updated 7-Sep-12 2:55am
v3
Comments
db7uk 7-Sep-12 8:56am    
your SELECT * FROM Name...... are you sure name is a table?
Anele Ngqandu 7-Sep-12 9:10am    
Try to rebuild your code if you have the table "Name"

Use commandBuilder yr problem will be solved.

C#
SqlCeDataAdapter da = new SqlCeDataAdapter("SELECT * FROM Name", con);
DataSet ds = new DataSet();
da.Fill(ds, "Name");
foreach (DataRow dr in ds.Tables["Name"].Rows)
{
    Console.WriteLine(dr["FirsName"] + "\t" + dr["NickName"] + "\t" + dr["Address"] + "\t" + dr["Gender"]);
    dr["Gender"]="Male";
}
SqlCommandBuilder sqlcmdBuild = new SqlCommandBuilder(da);
da.Update(ds.Tables["Name"]);
Console.Write("Press Enter to continue:");
Console.ReadLine(); 


Hope this will work
 
Share this answer
 
v2
Use
C#
da.Update(ds,"Name");
instead of
C#
da.Update(ds);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900