4 Replies - 628 Views - Last Post: 07 September 2012 - 12:06 PM Rate Topic: -----

#1 otomatis  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 07-March 11

Error when updating database from datatable

Posted 07 September 2012 - 05:41 AM

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) :
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

Is This A Good Question/Topic? 0
  • +

Replies To: Error when updating database from datatable

#2 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5316
  • View blog
  • Posts: 11,355
  • Joined: 02-June 10

Re: Error when updating database from datatable

Posted 07 September 2012 - 07:20 AM

Did you really name one of your tables "Table"?
Do you also name your dog "Dog", or a button "Button"?
That sort of thing is just asking for trouble and confusion.

Just a thought.. Since it seems to be a collection of people, maybe naming it "Employees" or "Students" or "Patients" as applies to your use of it might make a little more sense - and help you determine where you are going wrong.
Was This Post Helpful? 0
  • +
  • -

#3 MrShoes  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 312
  • View blog
  • Posts: 486
  • Joined: 13-June 12

Re: Error when updating database from datatable

Posted 07 September 2012 - 09:37 AM

I'm sure I've seen this before... isn't "Table" a reserved word?
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3160
  • View blog
  • Posts: 9,531
  • Joined: 05-May 12

Re: Error when updating database from datatable

Posted 07 September 2012 - 12:01 PM

I must be missing it. Where in the code posted in Post #1 is there a table named "Table"? From what I can see, there is a table named "Name".

This post has been edited by Skydiver: 07 September 2012 - 12:01 PM

Was This Post Helpful? 0
  • +
  • -

#5 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5316
  • View blog
  • Posts: 11,355
  • Joined: 02-June 10

Re: Error when updating database from datatable

Posted 07 September 2012 - 12:06 PM

Ok - 3 of us have now asked the OP if the table is really named that.
And they haven't replied. That was probably the problem and they can't be bothered to say 'thanks' or 'oops'. Personally I'm letting this one go
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1