Click here to Skip to main content
16,016,738 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am working in web project , I am using Dataadapter.update(dataset) method for batch insert but i am getting "Update unable to find TableMapping['Table'] or DataTable 'Table' " error, I searched on google but did not find any solution,


Code i am using to insert the data is:

dataset DS=new dataset();

IDbDataAdapter Da = ClsDataFactory.CreateAdapter(cmd, dbtype);

cmd.commandtext="storedprocedureName";
Da.InsertCommand = (SqlCommand)cmd;
Da.InsertCommand.Connection = (SqlConnection)con;

RecordAffected = Da.Update(DS);



Please help me. its very urgent!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Thanks in Adavance,

Sudhir
Posted
Updated 29-Jun-11 3:18am
v6
Comments
Vivek Krishnamurthy 29-Jun-11 9:28am    
Its not nice to say its urgent. please avoid in future

http://support.microsoft.com/kb/310376

Quote:
SQL
An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll

Additional information: Update unable to find TableMapping['Table'] or DataTable 'Table'.

To resolve this problem, make sure that the DataTable that you want to update is not Nothing or Null before you pass it into the Update method of the DataAdapter.


It looks like you're trying to pass an Update to an empty Dataset you've just created.
You need to fill the dataset with information:

http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/3adacd01-f08f-4059-bbce-bff736a5188e/

Something like:
Da.Fill(DS);
 
Share this answer
 
v4
Comments
Sudhir Kumar Srivastava lko 30-Jun-11 2:52am    
Dataset and datatable are not empty i have already check all these possibilities, now i am trying to map the column, if u have any solution please provide me.
Thx for response.
Take a look at this detailed example:

How To Update a SQL Server Database by Using the SqlDataAdapter Object in Visual C# .NET[^]

This should help!
 
Share this answer
 

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