473,322 Members | 1,431 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,322 software developers and data experts.

ObjectDataSource and Primary Key on DB Table

Environment:
XP sp2
VS.Net 2005 (Asp.Net 2.0 - c#)
Sql Server 2005

Scenario:
-Table (Table1) with two columns:
Table1Id <- Primary Key
Column1

-Standard CRUD stored procs; no fancy busines logic, just straight CRUD
actions
-The update sp updates Column1 where Table1Id = @Table1ID (Table1Id is not
updated).

In VS.Net 2005:
-Create a Typed DataSet (DataSet1) against Table1 and the stored procs
-Add WebForm1.aspx
-Drag on a GridView and bind it to DataSet1 for listing with and
ObjectDataSource (ObjectDataSource1)
-Drag on a FormView and bind it to DataSet1 for selected record retrieval
and updating with another ObjectDataSource (ObjectDataSource2)

Issue:
When I try to update the record I get the ...ObjectDataSource
'ObjectDataSource2' could not find a non-generic method 'Update' that has
parameters:... error. The primary key field (Table1Id) is being excluded
from the parameter list in the update attempt. The field in is shown to be
in typed dataset and both objectdatasources. I am NOT displaying Table1Id in
the gridview or the formview, but I am specifiing Table1Id as a DataKeyName
in GridView1. I've seen references to this error and scenario of missing the
primary key field all over the web. Apparently it is related to that fact
that the Primary Key field is not updated, so the update call excludes this
field. That doesn't match the update schema in the data set, so an error is
thrown. Usually the issue is resolved by making the Primary Key field
readonly=false in the GridView, but as I said, I'm not displaying the Primary
Key field.

As well, I can remove the Primary Key property from the table in the DB and
following the exact same setup and development procedure and everything works
fine.

It seems like a fairly common procedure to have a Primary Key field set in
the DB and a table updated on that field, so how do I make it work in VS.Net?
Is there a property I'm seeing that needs set? I essentially understand
what is happening, but I have trouble excepting the fact that I have to
remove and readd PK's for my tables as I'm developing the site against the DB.

Thanks.
Apr 13 '06 #1
0 1431

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

Similar topics

5
by: Ole M | last post by:
I'm having some trouble using the ObjectDataSource in ASP.NET 2.0. I have a wrapper that contains the static methods for Select and Update. The Update-method takes the business object as...
0
by: Nightcrawler | last post by:
Dear Group, I went ahead and used the wizards to create a dataaccesslayer of my database. I checked all my tables and in matter of a few seconds all my tables and relations appeard in VS2005. I...
0
by: Phil | last post by:
Environment: XP sp2 VS.Net 2005 (Asp.Net 2.0 - c#) Sql Server 2005 Scenario: -Table (Table1) with two columns: Table1Id <- Primary Key Column1
1
by: Scott F K Hooper | last post by:
VB.NET 2.0 project... I have an Access database with a table that has one primary key. I have used the Add TableAdapter wizard in VS2005 to create my TableAdapter. Next I added an ObjectDataSource...
1
by: Raja | last post by:
Hi Everybody Just playing with ObjectDataSource and noticed the following. I have a Gridview which binds to a ObjectDataSource. ObjectDataSource gets data from a typed dataset created with VWD. In...
0
by: Kevin | last post by:
Hi my name is Kevin I am currently working on a Asp 2.0 project and im having some ObjectDataSource Problems The thing is i have a Class called User and a Bussiness Logic Layer FcUser with...
0
by: Anabela Silva | last post by:
To anyone who has experienced this problem! Could not find a property named '... ' on the type specified by the DataObjectTypeName property in ObjectDataSource '...' I've been looking at...
1
by: Barry L. Camp | last post by:
Hi all, Wondering if someone can help with a nagging problem I am having using a GridView and an ObjectDataSource. I have a simple situation where I am trying to delete a row from a table, but...
1
by: Steve Kershaw | last post by:
Hi, I have a problem in which I'm using a GridView with an ObjectDataSource as a data source. The problem is that when I use the ObjectDataSource UPDATE routine I must have the key column...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.