473,387 Members | 1,779 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,387 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 1432

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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.