TableAdapter.Update doesn't work


Active member
Feb 9, 2013
Programming Experience
i'm new to this board and inurgent need of a solution to my c#-application problem.

i'm using visual c# 2008 xpress, sql srver 2005 xpress

that's what i do :

the dataset is ItemDataDS

SA.ItemDataDSTableAdapters.tblItemDataTableAdapter taItemData;
ItemDataDS ds = new ItemDataDS();
DataTable dt = ds.Tables[tablename];

i create and populate an array of objects ao and do : dt.LoadDataRow(ao,true);
when i check ds (debug) i find the table and in the table i find the data

finally i do : taItemData.Update(ds);

this is done without and error but when i check the db-table no data was written

the TableAdapters insert-, update-, select- and delete-methods work as i added and updated one record with the dataset-designer.
the fill() method also works 'cause this record can be seen in the ds.

any suggestions what i'm doing wrong or what i can do analyze the problem ?
thanks in advance
The first thing to do is to check the value returned by Update. Assuming an exception is not thrown, that value represents the number of records affected in the database. There are only two possibilities:

1. Update returns zero, in which case your DataTable did not contain any changes that could be saved by that adapter.
2. Update returns a non-zero value, in which case there were changes and they were saved.

Most likely in your case it is #2, which means that you are looking in the wrong place or at the wrong time for the data. To learn how to manage local data files, and therefore where and when to look for your data, follow the first link in my signature.
thanks for your reply
i have to apologize that i wasn't aware that Update() returns a value.
this shouldn't happen to an experienced programmer.
later on i'll check out this. i can't work with visual studio while online, visual studio gets soooooooooo sloooooooow (maybe ms is downloading all that errornous stuff from my machine ... ha,ha)
maybe in the meantime we could solve a second problem i got :
i can't work with visual studio and SQL Management Studio at the same time. the bad part of this is that when i close SQLMS and reopen VS, it can't connect to the database.
what i do is kill the sqlserv-service and restart it and everything works fine.
maybe you've got an advice for me how to handle this.
but today is sunday an one shouldn't be to much occupied with th pc.
by the way, everytime i do post i get the message that i'm not logged in, though the pageheader say welcome aw48. what i'm i doing wrong ?
Please keep each thread to a single topic and each topic to a single thread. If you have a question unrelated to the topic of this thread then please ask it in a new thread.
ok, i'll do so
now to the update-problem: (since english isn't my native language, some debug-expressions i don't know)
update() actually returns 0, but the data is in the table or at least it's the way i see it.
i point the cursor to the dataset which opens the treeview, then i select the table (in this case only one table belongs to the dataset).
then the bottom entry which says 'Input data' and this shows two rows with the data.
Since all of the columns except the two primary-key columns are of type sql-variant (System.Object in c#) i tested with another table which doesn't have sql-variant at all, but the result's the same.
Right now i do all the testing with a new project so i don't think it's a configuration problem.
by the way i can retrieve all the data currently in the database.
It might be time for you to show us ALL the RELEVANT code. You should also note that you can call GetChanges on a DataTable at any time to get a new DataTable containing just the changes, to see if and when there are changes in the table. You can also filter the type of change by specifying a DataRowState.
here it is :

since all is done with the designer, there isn't much code.

public partial class Form1 : Form
public Form1()

private void pbAddRow_MouseUp(object sender, MouseEventArgs e)
int n = dsItem.tblItem.Columns.Count;
ao = new Object[n];

ao[0] = "pos";
ao[1] = System.DateTime.Now;
ao[2] = "postext";
ao[3] = "app";


// connection open() and close() we can leave to the ta or
// we open() the connection here and ta will leave close() to us

int result = this.taItem.Update(dsItem);


Object[] ao;

some details :
dsItem.tblItem has 4 columns : Name (PrimaryKey, s10), Date(datetime, exceptsnull), Text(s30, exceptsnull), App(s10, exceptsnull)
with the designer, i added one row which was stored in the db.
with that handfull number of code i add a second row, which shows in the ds like this :

{12.02.2013 12:37:18}
(the values are listed in the columnheaders alphabetical order, thus "pos" is listed 3rd. {tblItem} i don't know. my guess is it's due to the primarykey)

this row is NOT stored !

have a nice day
You have set fAcceptChanges parameter to true, which means row state is set as Unchanged and there is no changes for the TableAdapter to update to database.
wow !!!
T R U E : four letters kept me busy for about 2 weeks. never thought about this.
thanx, thanx ,thanx
that's definetly worth 100 points !
Top Bottom