Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
hi,
 
i'm using visual c# 2008 xpress, sql srver 2005 xpress
the dataset is ItemDataDS
 
that's what i do :
 
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
Posted 9-Feb-13 12:20pm
fheyn702
Edited 8-Apr-13 3:35am
v2
Comments
Krunal Rohit at 9-Feb-13 23:11pm
   
Provide all the code !
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
fheyn at 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 at 10-Feb-13 8:56am
   
Start with the sample that works, then compare your work with that.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hi,
 
You might need to set the insert, update and delete command for your dataadapter.
 
SqlCommandBuilder cmdbuilder;
cmdbuilder = new SqlCommandBuilder(dataAdapt);
 
 
dataAdapt.DeleteCommand = cmdbuilder.GetDeleteCommand(true);
dataAdapt.UpdateCommand = cmdbuilder.GetUpdateCommand(true);
dataAdapt.InsertCommand = cmdbuilder.GetInsertCommand(true);
 


Best Regards
Muthuraja
  Permalink  
Comments
fheyn at 12-Feb-13 16:27pm
   
i don't use dataAdapter
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

You might want to use sqlcommandbuilder.
ex:
 
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
 
private void SaveChanges()              /* Save all changes made */
 
{
m_ComBuilder = new SqlCommandBuilder(m_DataAdapter);
   m_DataAdapter.Update(ds.Tables[tablename]);
}
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

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 !
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 485
1 BillWoodruff 330
2 OriginalGriff 310
3 Shweta N Mishra 244
4 Mathew Soji 225
0 OriginalGriff 6,153
1 Sergey Alexandrovich Kryukov 5,638
2 DamithSL 4,958
3 Manas Bhardwaj 4,539
4 Maciej Los 3,710


Advertise | Privacy | Mobile
Web04 | 2.8.1411019.1 | Last Updated 8 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100