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

Update Through A View Error: Table has no Primary Key

1
I am trying to update data in a datagrid that was generated by a view. I keep getting the error: "table has no primary key".

Here is the code that I am using:


Dim NewQuantity, NewAmount, NewrequestFilledBy, NewshipDate, Newtrackingid As String
Dim requestid As Integer

NewQuantity = CType(e.Item.Cells(3).Controls(0), TextBox).Text
NewAmount = CType(e.Item.Cells(4).Controls(0), TextBox).Text
NewrequestFilledBy = CType(e.Item.Cells(9).Controls(0), TextBox).Text
NewshipDate = CType(e.Item.Cells(10).Controls(0), TextBox).Text
Newtrackingid = CType(e.Item.Cells(11).Controls(0), TextBox).Text


requestid = dgPath.DataKeys(e.Item.ItemIndex)

Dim RgRow As dsPath.vwPathViewRow
RgRow = DsPath.Tables.Add.Rows.Find(requestid)


RgRow.quantity = NewQuantity
RgRow.amount = NewAmount
RgRow.requestFilledBy = NewrequestFilledBy
RgRow.shipDate = NewshipDate
RgRow.trackingID = Newtrackingid


Try
OleDbDataAdapter1.Update(DsPath)
Session("mydataset") = DsPath
Catch ex As DBConcurrencyException
Label1.Text = "This row has been updated by another user!"
DsPath.Clear()
OleDbDataAdapter1.Fill(DsPath)
Me.DataBind()

End Try
dgPath.EditItemIndex = -1
dgPath.DataBind()


Help with this would be greatly appreciated.
Aug 17 '07 #1
2 1276
jhardman
3,406 Expert 2GB
moved to .NET forum
Aug 20 '07 #2
nateraaaa
663 Expert 512MB
I am trying to update data in a datagrid that was generated by a view. I keep getting the error: "table has no primary key".

Here is the code that I am using:


Dim NewQuantity, NewAmount, NewrequestFilledBy, NewshipDate, Newtrackingid As String
Dim requestid As Integer

NewQuantity = CType(e.Item.Cells(3).Controls(0), TextBox).Text
NewAmount = CType(e.Item.Cells(4).Controls(0), TextBox).Text
NewrequestFilledBy = CType(e.Item.Cells(9).Controls(0), TextBox).Text
NewshipDate = CType(e.Item.Cells(10).Controls(0), TextBox).Text
Newtrackingid = CType(e.Item.Cells(11).Controls(0), TextBox).Text


requestid = dgPath.DataKeys(e.Item.ItemIndex)

Dim RgRow As dsPath.vwPathViewRow
RgRow = DsPath.Tables.Add.Rows.Find(requestid)


RgRow.quantity = NewQuantity
RgRow.amount = NewAmount
RgRow.requestFilledBy = NewrequestFilledBy
RgRow.shipDate = NewshipDate
RgRow.trackingID = Newtrackingid


Try
OleDbDataAdapter1.Update(DsPath)
Session("mydataset") = DsPath
Catch ex As DBConcurrencyException
Label1.Text = "This row has been updated by another user!"
DsPath.Clear()
OleDbDataAdapter1.Fill(DsPath)
Me.DataBind()

End Try
dgPath.EditItemIndex = -1
dgPath.DataBind()


Help with this would be greatly appreciated.
Let's start at the beginning. What is the primary key of the table? Are you trying to update the view or the table that the view is based on?
Aug 20 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jim Geissman | last post by:
Help, please. I am trying to update a table with this structre: CREATE TABLE Queue (PropID int, EffDate smalldatetime, TxnAmt int) INSERT Queue (PropID) SELECT 1 INSERT Queue (PropID)...
8
by: Jason | last post by:
I have a table that matches up Securities and Exchanges. Individual securities can belong on multiple exchanges. One of the columns, named PrimaryExchangeFlag, indicates if a particular exchange is...
4
by: Mark S. | last post by:
Hi, I have a weird UPDATE sequence I want to perform. The customer does not want to use INSERT and DELETE. My issue is that there are multiple Mat_Class, but I do not wish to hard code each one...
2
by: serge | last post by:
/* This is a long post. You can paste the whole message in the SQL Query Analyzer. I have a scenario where there are records with values pointing to wrong records and I need to fix them using an...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
5
by: Timothy Perrigo | last post by:
This bug? feature? caused a bit of havoc for us yesterday...A reproducible example follows. Essentially, if you have a table with a primary key called "id", and you create a temp table (via a...
7
by: Jon Maz | last post by:
Hi, I have a MySql problem I hope someone can help me with. I'm trying to run an update on a linking table, the update is running into a Primary Key constraint violation, and in my workaround...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
1
by: crichard1983 | last post by:
I'm using a Unique Key constraint for the first time, and I think I may not be understanding something correctly. I have a table with a Primary key (media_format_id) that is auto-increment. Then I...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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...
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...
0
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...
0
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...

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.