473,769 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ObjectDataSourc e 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
ObjectDataSourc e (ObjectDataSour ce1)
-Drag on a FormView and bind it to DataSet1 for selected record retrieval
and updating with another ObjectDataSourc e (ObjectDataSour ce2)

Issue:
When I try to update the record I get the ...ObjectDataSo urce
'ObjectDataSour ce2' 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 objectdatasourc es. 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 1462

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

Similar topics

5
1990
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 parameter. When the Update-method is invoked by the ObjectDataSource, the object referenced is not the same object returned by the Select-method, but a new object with only the values from the Edit-template. So basically I get a reference to a useless...
0
1440
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 then configured the dataadapters for each table to use automatically created stored procedures by VS2005. Each table now has a select, insert, update, delete query. So far so good. The problem happens when I try to bind a table (Products) to a...
0
355
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
2495
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 object to a new aspx form, chosen the newly created TableAdapter and selected the parameterised Update command from the drop list provided. Finally I added a GridView control and bound it to the ODS. The problem I have is an error I get when...
1
2440
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 the table from which the data is coming has a Primary Key field. Gridview is set to edit mode. DataKeyNames = "PK_Field". Now if PK field is not readonly, then data is updated successfully. But if I set PK Field to readonly, then data is not...
0
1477
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 the functions GetAllUsers, GetUserByID(int) and a InsertUser(BoUser as User), the both return a generic list of User objects, the insert method sends a User object from my UI provided by the ObjectDatasource
0
3640
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 forums about the problem that devellopers have in using ObjectDataSource when trying to update or delete a record. There has been a lot of talk like... you have to implement a list if you wanna use direct methods in such operations, etc etc
1
8580
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 it doesn't seem to work at all. Below is my ASP.NET page, and further below, my VB.NET method that I am trying to call: <div id="admin-faq" class="page"> <h2>Site FAQs (Frequently Asked Questions)</h2>
1
1660
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 displayed (and editable) in the GridView! This is a problem because this key column is the database table key value and can't be changed. If I don't display the key column or if I set it as ReadOnly then the ObjectDataSource UPDATE routine dosen't see...
0
9422
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10208
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9987
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8867
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7404
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3952
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.