Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I've got a dataset and several tables in it, using VB.Net(VS 2012). Everything is working fine i can add or delete any table from the dataset whenever I want to except for one particular table. Whenever I am adding it, It is giving me the following error.

"Failed to add adapter"
"An item with the same key has already been added"

Please help.
Posted

1 solution

You should check first if the table with the same key already exists in dataset or not.

If (ds.Tables.Contains(tableName)) Then

   ' Here you can remove first and re-add, if there are some updates in the table you are going to add.
   ' On the other hand no need to define ELSE case as you can't re-add them if already exists  
End If
 
Share this answer
 
Comments
Aziz Sheikh 31-Dec-14 3:20am    
Thanks for the reply. I tried your method but there is no table with the name I am having trouble with. And besides this I am using the designer to add the tableadapter.
Shahan Ayyub 31-Dec-14 6:37am    
Can you please show us how do you do it then in designer ?
Aziz Sheikh 1-Jan-15 4:13am    
Well I hope i could explain it. Anyways, I go in the designer right click and add table adapter and then I select the table from the database. After that when i click finish i get the said error.

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