User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 426,593 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,656 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser: Programming Forums
Views: 332 | Replies: 3 | Solved
Reply
Join Date: Jun 2008
Posts: 3
Reputation: edrrit is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
edrrit edrrit is offline Offline
Newbie Poster

Small (and probably stupid) problem with dataset

  #1  
Jun 24th, 2008
Hello everyone,

as will be seen from the following massage I am new to C#.
I have dataGrid that reads data from mine database. Also, I can update database from dataGrid, but I want to update it in more ways. So, I have the following code just to see something, but to mine big surprise it does not give me the results that I expect:

dataSet1.Tables["Example"].Rows[i].ItemArray[j]=33 ;
MessageBox.Show(dataSet1.Tables["Example"].Rows[i] .ItemArray[j].ToString());

MessageBox shows me the old value (the value is not changed). Why is that?

Thanks in advance.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2006
Location: Egypt
Posts: 762
Reputation: RamyMahrous is on a distinguished road 
Rep Power: 4
Solved Threads: 59
Featured Poster
RamyMahrous's Avatar
RamyMahrous RamyMahrous is offline Offline
Master Poster

Re: Small (and probably stupid) problem with dataset

  #2  
Jun 24th, 2008
Did you commit the changes done at the dataset?!
B.Sc Computer Science, Helwan University
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
Reply With Quote  
Join Date: Jun 2008
Posts: 3
Reputation: edrrit is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
edrrit edrrit is offline Offline
Newbie Poster

Re: Small (and probably stupid) problem with dataset

  #3  
Jun 25th, 2008
Originally Posted by RamyMahrous View Post
Did you commit the changes done at the dataset?!

Yes, I have tried it (it was also mine first guess), but with no results. I am doing something wrong, but don’t know what.

The row remains unchanged. For example the following code would give me message: “unchanged”

dataSet1.Tables["Example"].Rows[i].ItemArray[j]=33;
MessageBox.Show(dataSet1.Tables["Example"].Rows[i].RowState.ToString());

In despair I have tried all the combinations (before and after the line where I have tried to assign new value to the row):

dataSet1.AcceptChanges();
dataSet1.Tables["Example"].AcceptChanges()
dataSet1.Tables["Example"].Rows[i].AcceptChanges()

The result is always the same – I can’t change anything, and I remind you that when I try the same thing with DataGrid it works just fine.

Mine next guess was that DataGrid locks in some way Dataset (stupid guess, but I was desperate) and I’ve tried the whole thing without Dataset, but with no results again.

Mine guess is that I am not committing changes in a Dataset the way I should, but I can’t find a mistake.
Reply With Quote  
Join Date: Jun 2008
Posts: 3
Reputation: edrrit is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
edrrit edrrit is offline Offline
Newbie Poster

Re: Small (and probably stupid) problem with dataset

  #4  
Jun 25th, 2008
Sorry for wasting your time.

Mine case is proof that it is good to leave the code when you are tired and to come back to it later on. I forgot to put the following line:

oleDbDataAdapter1.Update(dataSet1,”Example”)

While I was searching for some complex solutions I did not check basic things...
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C# Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the C# Forum

All times are GMT -4. The time now is 10:49 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC