471,627 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

Any obvious reason why this won't work?

I'm just beginning to learn ADO.NET and have taken some code from
the book "Pro ADO.NET 2.0". When I run this application the "Validated"
MessageBox gets displayed but when I quit and rerun the application it
appears that the database is has not been updated.

The information displayed in the DataGrid is shown so I assume the
connection to the database is fine.

private void demoBindingNavigatorSaveItem_Click(object sender,
EventArgs e)
{
if (this.Validate())
{
System.Windows.Forms.MessageBox.Show(this,
"Validated.",
"Save",
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Information);
this.demoBindingSource.EndEdit();
this.demoTableAdapter.Update(this.testDataSet.Demo );
}
else
{
System.Windows.Forms.MessageBox.Show(this,
"Validation errors
occurred.",
"Save",
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Warning);
}

Any help appreciated.

Regards
Chris Saunders
Feb 20 '06 #1
2 1199
Hi Chris,

Your message was brought to my attention by Frans Bouma, so here I am.

I believe you are talking about the DragDropWinApp application in Chapter
#3. If that is incorrect, please let me know.

Assuming that we are talking about the same application - I can't seem to
replicate your problem. The code sample is working absolutely fine at my
end.

When you run the application it shows one row "1, Hello World", which was
queried out of the database. When you hit "Save" without modifying any data,
since you didn't change any data, no queries get run.
Now when you modify the data to "1, Bubye World", and hit the Save button -
and then close the application, and rerun the application, you will indeed
see your changes persisted to the database.

So to the best of my knowledge, this code sample is working correctly. If
there is still any confusion please contact me directly through my blog.

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.ma.../13/63199.aspx
__________________________________________________ ________
"Chris Saunders" <ev**@mountaincable.net> wrote in message
news:38***************************@MOUNTAINCABLE.N ET...
I'm just beginning to learn ADO.NET and have taken some code from
the book "Pro ADO.NET 2.0". When I run this application the "Validated"
MessageBox gets displayed but when I quit and rerun the application it
appears that the database is has not been updated.

The information displayed in the DataGrid is shown so I assume the
connection to the database is fine.

private void demoBindingNavigatorSaveItem_Click(object sender,
EventArgs e)
{
if (this.Validate())
{
System.Windows.Forms.MessageBox.Show(this,
"Validated.",
"Save",

System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Information);
this.demoBindingSource.EndEdit();
this.demoTableAdapter.Update(this.testDataSet.Demo );
}
else
{
System.Windows.Forms.MessageBox.Show(this,
"Validation errors
occurred.",
"Save",

System.Windows.Forms.MessageBoxButtons.OK,

System.Windows.Forms.MessageBoxIcon.Warning);
}

Any help appreciated.

Regards
Chris Saunders

Feb 20 '06 #2
Chris Saunders - Cox Cable RI Chris Saunders ?
"Chris Saunders" <ev**@mountaincable.net> wrote in message
news:38***************************@MOUNTAINCABLE.N ET...
I'm just beginning to learn ADO.NET and have taken some code from
the book "Pro ADO.NET 2.0". When I run this application the "Validated"
MessageBox gets displayed but when I quit and rerun the application it
appears that the database is has not been updated.

The information displayed in the DataGrid is shown so I assume the
connection to the database is fine.

private void demoBindingNavigatorSaveItem_Click(object sender,
EventArgs e)
{
if (this.Validate())
{
System.Windows.Forms.MessageBox.Show(this,
"Validated.",
"Save",

System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Information);
this.demoBindingSource.EndEdit();
this.demoTableAdapter.Update(this.testDataSet.Demo );
}
else
{
System.Windows.Forms.MessageBox.Show(this,
"Validation errors
occurred.",
"Save",

System.Windows.Forms.MessageBoxButtons.OK,

System.Windows.Forms.MessageBoxIcon.Warning);
}

Any help appreciated.

Regards
Chris Saunders

Feb 24 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Michele Simionato | last post: by
14 posts views Thread by Joe Powell | last post: by
2 posts views Thread by Steven D'Aprano | last post: by
12 posts views Thread by Ashu | last post: by
28 posts views Thread by H J van Rooyen | last post: by
4 posts views Thread by robertcode | last post: by
16 posts views Thread by John Salerno | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.