473,385 Members | 1,267 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Updating Dataset

Hi

I am new to ASP.NET and I'm trying to follow the following MSDN
Walkthrough
(http://msdn.microsoft.com/library/de...dwritedata.asp)
regarding datagrids and pushing and pulling data from a database.
I am using an Oracle database with a larger table, but otherwise I am
following the walkthrough exactly. Everything is working properly
except for when I update the data set. I am unable to call a 'find'
method that the walkthrough claims should have been generated
automatically:

// Finds the row in the dataset table that matches the
// one the user updated in the grid. This example uses a
// special Find method defined for the typed dataset, which
// returns a reference to the row.
dsCategories.CategoriesRow r;
r = dsCategories1.Categories.FindByCategoryID(int.Pars e(key));

The program complains that the FindByCateogryID method is not present
and so the program is unable to update the dataset. I have checked the
Categories class and there is no method that looks remotely close to
the FindByCategoryID method.
Can anyone help me?

Thanks

Nov 19 '05 #1
3 1223
Hi,
Can you verify if the CategoryID is the primary column in your
database table? If it is not, that could be the problem. One option is
to set the primary column in the table and regenerate the dataset.

Thanks.
Arun Prakash. B

Nov 19 '05 #2
Thanks Arun!

The method is now showing up and the web app is now compiling properly.
However, I started getting an error from this line:

// Calls a SQL statement to update the database from the dataset
oracleDataAdapter1.Update(dataSet11);

The error I recieved was as follows:
InvalidOperationException: Update requires a valid UpdateCommand when
passed DataRow collection with modified rows

I was able to fix it by adding the following line before the Update
command:

System.Data.OracleClient.OracleCommandBuilder cmd = new
System.Data.OracleClient.OracleCommandBuilder(orac leDataAdapter1);

And it is updating without generating any errors, however it is
shifting the data one row to the left every time it updates. For
example a row would look like this:
1 2 3 4 5 6 7
And after clicking on edit and then update without changing any cells
the row would look like this:
2 3 4 5 6 7 7

Anyone know how I can fix this?
Thanks
ar**********@gmail.com wrote:
Hi,
Can you verify if the CategoryID is the primary column in your
database table? If it is not, that could be the problem. One option is
to set the primary column in the table and regenerate the dataset.

Thanks.
Arun Prakash. B


Nov 19 '05 #3
Figured it out...

I was copying the wrong cells, the MSDN walkthrough code had an extra
read only column at the beggining that I didn't.

Thanks again for your help Arun.

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Robin | last post by:
In a .Net solution that has a DAL, Class and Business logic. When recreating a dataset from the class the records are inserted into the database from the dataset instead of updating. This is using...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
10
by: jaYPee | last post by:
does anyone experienced slowness when updating a dataset using AcceptChanges? when calling this code it takes many seconds to update the database SqlDataAdapter1.Update(DsStudentCourse1)...
14
by: Lars Netzel | last post by:
A little background: I use three Datagrids that are in a child parent relation. I Use Negative Autoincrement on the the DataTables and that's workning nice. My problem is when I Update these...
4
by: Geoff | last post by:
Hi I'm hoping somebody can help me with the following problem that has occurred to me. Suppose I have two tables in an SQL Server database. Let's call these tables A and B. Assume that A has...
2
by: susan.f.barrett | last post by:
Hi, Despite me being able to type the following in to SQL Server and it updating 1 row: > updatestockcategory 1093, 839 In my code, it is not updating any rows. dataSet = new DataSet();
6
by: Rich | last post by:
Dim da As New SqlDataAdapter("Select * from tbl1", conn) dim tblx As New DataTable da.Fill(tblx) '--works OK up to this point da.UpdateCommand = New SqlCommand da.UpdateCommand.Connection =...
6
by: mike11d11 | last post by:
I'm trying to create an application that will have multiple users working off a table on a SQL server. Since multi users will be updating different records at any given moment, how can i get those...
0
by: OldStd | last post by:
Updating data using 2 data sets I am having some problems in updating the database using two datasets as suggested by someone. 1. Data is displayed in a data grid from a dataset generated using...
1
by: jonbartlam | last post by:
Hi There I'm not sure what exactly is going wrong here. I'm writing an application that retreives a table from a database (tbl_internalfaults) and updates it. (Actually, just the status column will...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.