Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

i'm using visual c# 2008 xpress, sql srver 2005 xpress
the dataset is ItemDataDS

that's what i do :

C#
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 :
C#
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
Posted
Updated 7-Nov-18 20:36pm
v2
Comments
[no name] 9-Feb-13 23:11pm    
Provide all the code !

 
Share this answer
 
Comments
fheyn 10-Feb-13 7:12am    
sorry, but this isn't very helpfull.
all that stuff seven or eight times before in the last ten days.
i built a new testproject from scratch this morning and it gets the same problem.
there is already some data in the db and i can retrieve it without any problem, but i can't neither insert nor update (delete i havn't tried, bet delete's gonna work).
Mehdi Gholam 10-Feb-13 8:56am    
Start with the sample that works, then compare your work with that.
Hi,

You might need to set the insert, update and delete command for your dataadapter.

VB
SqlCommandBuilder cmdbuilder;
cmdbuilder = new SqlCommandBuilder(dataAdapt);
 

dataAdapt.DeleteCommand = cmdbuilder.GetDeleteCommand(true);
dataAdapt.UpdateCommand = cmdbuilder.GetUpdateCommand(true);
dataAdapt.InsertCommand = cmdbuilder.GetInsertCommand(true);



Best Regards
Muthuraja
 
Share this answer
 
Comments
fheyn 12-Feb-13 16:27pm    
i don't use dataAdapter
You might want to use sqlcommandbuilder.
ex:

C#
SqlDataAdapter m_DataAdapter;           /* data adapter */
ItemDataDS ds = new ItemDataDS();       /* dataset */
DataTable dt = ds.Tables[tablename];    /* datatable */
SqlCommandBuilder m_ComBuilder;         /* command builder */

private void LoadData()                 /*populate your dataset*/
{
 m_DataAdapter = new SqlDataAdapter("Select ... from ..",Connection)
 m_DataAdapter.Fill(ds.Tables[tablename]);
}


... add row or make changes on your datatable

C#
private void SaveChanges()              /* Save all changes made */

{
m_ComBuilder = new SqlCommandBuilder(m_DataAdapter);
   m_DataAdapter.Update(ds.Tables[tablename]);
}
 
Share this answer
 
v2
this is the solution :

dt.LoadDataRow(ao,FALSE);

with AcceptChanges-flag set TRUE, there is NO update !

don't mind the message board's message

i didn't solve it myself !
 
Share this answer
 
v2
I have same problem and I can say:

just dont use tableadapter AcceptChanges method


my vb.code in vs 2008

Dstrading.TImpMabna.Rows.Add(k)

 Dstrading.TImpMabna.AcceptChanges()

 Me.Validate()
 Me.BsTImpMabna.EndEdit()


   TaTImpMabna.Update(Me.Dstrading.TImpMabna)

   Me.TableAdapterManager.UpdateAll(Me.Dstrading)
 
Share this answer
 
Comments
CHill60 8-Nov-18 4:09am    
Reasons for my downvote:
- The OP already pointed out the problem with the AcceptChanges flag</>.
- You have contradicted yourself by sayng "dont use" the method and then post an solution that uses that method
- The question was tagged as C# and you have posted a VB solution

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