Wrox Programmer Forums
|
BOOK: Beginning Visual C#
This is the forum to discuss the Wrox book Beginning Visual C#, Revised Edition of Beginning C# for .NET v1.0 by Karli Watson, David Espinosa, Zach Greenvoss, Jacob Hammer Pedersen, Christian Nagel, Jon D. Reid, Matthew Reynolds, Morgan Skinner, Eric White; ISBN: 9780764543821
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 8th, 2003, 07:17 PM
Registered User
 
Join Date: Oct 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Updating a database

Question from a newbie:

I am playing around with the various topics in "Beginning Visual C#" and I am stuck on a problem.

I have worked through the section on updating a database (beginning on page 622) and everything works great but what I would like to do is specify a row to update.

What I have at the moment is this:

private void btnUpdate_Click(object sender, System.EventArgs e)
{
_adapter.UpdateCommand = new OleDbCommand("UPDATE tbl_person SET first_name = '" +
_dataset.Tables["tbl_person"].Rows[0]["first_name"] + "', last_name = '" +
_dataset.Tables["tbl_person"].Rows[0]["last_name"] + "' WHERE pay_no = '" +
_dataset.Tables["tbl_person"].Rows[0]["pay_no"] + "'", _connection);
_adapter.Update(_dataset, "tbl_person");
}

and it works really well if I specify which row to update eg 0, 1, 2 etc by physically changing the value of the row.

What I would like to do is pass the row value to the SQL command according to the field that is currently displayed. eg if fred bloggs details are on the screen (lets say he's record 3) and I click the update button then I want it to pass the record value to the SQL update command.

I would like to ask everyone their thoughts on how to do this because I think I am confusing myself with it somewhere along the line and I'm getting nowhere.

Thanks in advance....:)

 
Old October 9th, 2003, 05:15 AM
Authorized User
 
Join Date: Aug 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Chris Beach Send a message via AIM to Chris Beach Send a message via MSN to Chris Beach Send a message via Yahoo to Chris Beach
Default

so you know the unique index of the person you want to update?

If so then your SQL Update is sommit like this:
UPDATE tbl_person SET first_name=*NEW NAME* WHERE unique_id=3

Is that what your after?

If you don't know the unique ID, then you need to get it at the same time you get the rest of the information (like his name's etc)






Similar Threads
Thread Thread Starter Forum Replies Last Post
updating database musicradiolive Classic ASP Databases 1 August 17th, 2006 12:23 AM
database not updating ellie BOOK: Beginning ASP 3.0 1 April 16th, 2006 05:28 AM
Help for Updating the database bspradeep Classic ASP Databases 1 May 10th, 2005 03:13 AM
updating database texasraven ASP.NET 1.x and 2.0 Application Design 2 September 21st, 2004 05:14 PM
Updating a database Gary_M Classic ASP Databases 4 November 7th, 2003 11:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.