Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 April 6th, 2006, 03:45 PM
Registered User
 
Join Date: Apr 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Editing Data in a DataView

I'm a beginner programmer in C# asp.NET and am currently working on a web portal as a college project. My question is, how do you change data that's in a dataview?

I have a dataset, and a dataview pointing to that dataset. (I'm away from the code at the moment, so syntax might not be perfect)

Code:
dv.table = ds.TABLE;
dv.sort = "POSITION";
dv.rowviewfilter = "ID>=" + variable;


Then I try to assign it to stuff:

Code:
dv[0]["POSITION"] = 125;


or read things out:

Code:
variable = dv[0]["ID"];


Also, I write the changes to the database using my own SQL statements.

But it doesn't seem to work. It compiles fine, but the changes don't appear on the page or in the database.

I hope this makes sense. Thanks for your help!



 
Old April 7th, 2006, 08:55 PM
Registered User
 
Join Date: Apr 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have the exact code now. It's a function that swaps two locations.

Code:
int HighLocation, LowLocation;
ModuleDataView.Table = UserInfoDSInstance.USERMODULE;            
ModuleDataView.Sort = "UMPOSITION";
ModuleDataView.RowFilter = "MID=" + CallingModule;
HighLocation = (int)ModuleDataView[0]["UMPOSITION"];
ModuleDataView.Table = UserInfoDSInstance.USERMODULE;            
ModuleDataView.Sort = "UMPOSITION";
ModuleDataView.RowFilter = "UMPOSITION>=" + HighLocation;
LowLocation = (int)ModuleDataView[1]["UMPOSITION"];
ModuleDataView[0]["UMPOSITION"] = LowLocation;
ModuleDataView[1]["UMPOSITION"] = HighLocation;
oracleUpdateCommand1.CommandText = "UPDATE USERMODULE SET UMPOSITION = " + LowLocation + " WHERE MID = " + (int)ModuleDataView[0]["MID"] + " AND USERID = '" + UserID + "'";
OracleConnection.Open();
oracleUpdateCommand1.ExecuteScalar();
oracleUpdateCommand1.CommandText = "UPDATE USERMODULE SET UMPOSITION = " + HighLocation + " WHERE MID = " + (int)ModuleDataView[1]["MID"] + " AND USERID = '" + UserID + "'";
oracleUpdateCommand1.ExecuteScalar();
OracleConnection.Close();
The changes are not being written to the database. Not sure why...

 
Old April 10th, 2006, 11:25 AM
Registered User
 
Join Date: Apr 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

anybody?? :(

 
Old April 10th, 2006, 09:40 PM
Registered User
 
Join Date: Apr 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

nevermind...figured it out.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Binding - Editing GridView Row Data desk_star BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 7 December 30th, 2007 11:07 AM
Data Grid Editing in C# bmains C# 1 December 16th, 2004 04:23 AM
What is the code for editing data bisigreat VB How-To 2 August 19th, 2004 03:06 AM
Editing Access and import data edramail Access 2 May 7th, 2004 02:27 AM
Data Grid editing of class bmains Pro VB.NET 2002/2003 3 October 22nd, 2003 12:38 PM





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