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

Update requires a valid UpdateCommand error

SAL
Hello,
I'm working on a webform that is utilizing an objectdatasource for a
detailsview web control (asp.net 2.0). I used the designer to generate the
dataset for my project and this objectdatasource is linked to a business
logic layer class that I created that is based on the dataset that was
created via the designer. There is an annex table adapter and with that I
had the designer generate update, insert and delete commands when I
generated the getAnnex query by checking the "GenerateDBDirectMethods"
checkbox.
So in my details view I click edit, modify the record and then click the
Update button. This executes the UpdateAnnex method in my business class
where the following code is executed:
The exception is raised on the last line of code before the return
statement. I looked at the class view and it shows an update command that
takes a DataRow as an argument so I'm confused by the error. Can anyone help
me with this?

Public Function UpdateAnnexation(ByVal dateReceived As Nullable(Of
DateTime), _
ByVal name As String, _
ByVal estimatedTaxImpacts As Nullable(Of Decimal), _
ByVal estimatedAssessedValue As Nullable(Of Decimal), _
ByVal gsReview As Nullable(Of DateTime), _
ByVal statuteId As Nullable(Of Integer), _
ByVal statuteRequirementsMet As Boolean, _
ByVal annexationId As Integer) As Boolean

Dim annexs As Annexationds.AnnexationsDataTable
annexs = Adapter.GetAnnexationByAnnexationId(annexationId) ' returns
a datatable
If annexs.Count = 0 Then
Return False
End If

Dim annex As Annexationds.AnnexationsRow = annexs(0)
If dateReceived.HasValue Then
annex.DateReceived = dateReceived
End If

With annex
If Not estimatedTaxImpacts.HasValue Then
annex.SetEstimatedTaxImpactsNull()
Else
.EstimatedTaxImpacts = estimatedTaxImpacts
End If
If Not estimatedAssessedValue.HasValue Then
annex.SetEstimatedAssessedValueNull()
Else
.EstimatedAssessedValue = estimatedAssessedValue
End If
If gsReview.HasValue Then
annex.GSReview = gsReview
Else
annex.SetGSReviewNull()
End If
If statuteId.Value <annex.StatuteId Then
annex.StatuteId = statuteId.Value
End If
annex.StatuteRequirementsMet = statuteRequirementsMet
End With

Dim affectedrows As Integer = Adapter.Update(annex)
Return affectedrows = 1
End Function
Mar 16 '07 #1
0 1064

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

Similar topics

1
by: Yog | last post by:
I have a datagrid binded to a dataset and once the user updates the grid my dataset is reflected. When i wanted to save the data to tables, however i needed to insert this data into another...
2
by: Mojtaba Faridzad | last post by:
Hi, Please check these lines: DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet, "mytable"); DataRow row; row = dataSet.Tables.Rows; row.BeginEdit(); row = "555";
1
by: MrMike | last post by:
Hi. My application has dozens of datagrids but for some reason an exception occurs when one of them is updated. When a user edits a datagrid row and then clicks 'Update' the following exception...
6
by: Wanda | last post by:
Hello, I tried to update a row in a table by using the datarow and data adapter. Unfortunately, it doesn't update. I try finding that datarow and set it to "dr", I can see dr could be just an...
1
by: Moomin Ma | last post by:
I have create a excel file with 2 columns and 2 rows for demonstration. The excel file is then opened by ms access and therefore a mdb file was created. The mdb file showing the correct linkage...
7
by: Jean Christophe Avard | last post by:
Hi! I have a dataset that retreive all the item information from the database. I need to be able to edit them, in the dataset and in the database. I have this code, could anyone tell me if I'm...
4
by: George | last post by:
Hi all, I am having trouble with updating my data in an Access database. here is my code: Imports System.Data.OleDb Dim AppPath As String = Mid(Application.ExecutablePath, 1,...
2
by: Hexman | last post by:
Hello All, Well I'm stumped once more. Need some help. Writing a simple select and update program using VB.Net 2005 and an Access DB. I'm using parameters in my update statement and when trying...
2
by: travhale | last post by:
in a new project using .net 2005, c#. getting err message "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." source RDBMS is oracle 8i. I add a new...
1
by: mikalush | last post by:
is anyone know if i can update access database with dataset in the vs 2005 express? really imortant to me. i need to know maybe i just wasting my time! i've a datagridView that get is data...
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:
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
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: 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
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
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
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
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,...

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.