#### Archived

This topic is now archived and is closed to further replies.

# C# Updating a Table

This topic is 5662 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am having problems updating a Microsoft.Data.Odbc.DataTable with new data. I want to be able to do this by using regular SQL commands, and I cannot find a decent example or information to get this working. Right now I have this
   //dt has been filled and named

da.UpdateCommand = new Odbc.OdbcCommand("UPDATE " + dt.TableName + " SET Value = 0 WHERE Name=''PartLength''");
da.Update(dt);  
Simple, but I thought it would work. I get no errors when running this code, its just that when I do it the values in the datatable remain what they were prior to running it. If anyone knows how I can do this properly (so that the values actually update) please let me know. Also, I probably didn''t provide enough information so let me know what you need to answer the question. Thank you.

##### Share on other sites
Is there a Commit() method or something similar? Maybe you have to tell the db driver you want to keep the changes.

##### Share on other sites
The DataTable has an AcceptChanges() method but it is supposed to be called by the Update() Method. I tried adding it anyway, and I get the same results.

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
17

• 10
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631420
• Total Posts
2999987
×