Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataGridView
Message
From
07/11/2007 23:10:40
 
 
To
07/11/2007 16:16:43
General information
Forum:
ASP.NET
Category:
Forms
Title:
Environment versions
Environment:
C# 2.0
OS:
Vista
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01267049
Message ID:
01267510
Views:
18
Sergio,

>Thanks!. Now it is working perfect.

You're welcome! =0)

>Bonnie my next step is to save the changed row back to the database.
>I am confused (nothing new!!)on how to save the row back to the database.


Sorry I didn't get back to you earlier ... kinda swamped with work today.

Anyway, what you do not want to do is the m_Row.Table.AcceptChanges(). What that does, in effect, is commit all your changes to the DataTable. So, when you *do* try to send updates to your database, the DataTable won't know that it has any changes.

The rest of it is fine ... you can send the update to the database for only the changed Row if you want to, or for everything that gets changed. Part of how you do that probably depends on how you plan to do the database update ... most newbies use the TableAdapter, but I think that's a bad habit to get into. You've probably seen my recent posts floating around on here showing various methodologies for DataAccess.

~~Bonnie


>
>Here is my logic:
>
>On my producer form I have OK(save) button and close button, see code :
>
>
> private void btnClose_Click(object sender, EventArgs e)
> {
>   m_Row.RejectChanges();
>   this.Close();
> }
>
>  private void btnOK_Click(object sender, EventArgs e)
>   {
>      m_Row.Table.AcceptChanges();
>      this.Close();
>   }
>
>
>Now when I get back to my Agency form,I call an update method on my Bussiness layer to update ONLY the DataRow.
>
>Agency has many producers, that is why I have a DataGridView on my Agency form.
>Here is the code :
>
>  private void btnProducerEdit_Click(object sender, EventArgs e)
>  {
>    int i = grdProducers.CurrentRow.Index;
>    DataRow row = dsProducers.Tables["Producers"].DefaultView[i].Row;
>    Producer frmProducers = new Producer(row,i);
>    frmProducers.Text = "Producers";
>    frmProducers.ShowDialog();
>
>    // Bonnie here is where I would call my Update method in my
>    // business layer
>
>
>
>  }
>
>
>
>Does it make sense??. I just want to go back and only save the DataRow that was changed on the producer form. Since there might be another changes on the Agency form that the user still has not commit.
>
>Maybe I should do the update on the producer form? But if I do it there I guess I would need to pass the DataSet.
>
>
>
>Sergio
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform