473,326 Members | 2,805 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,326 software developers and data experts.

Dataset Designer problems

SAL
I'm curious if anyone else is having this problem. If I let the Dataset
designer generate update commands for me, I don't seem to be able to get
them to work without an exception getting thrown, (Update requires a valid
UpdateCommand), but if I execute the following code it does work. It seems
like a total waste of time to have to write the following code if the
dataset designer can generate the code:

Dim annexs As New SqlDataAdapter
Dim sql As String = "SELECT DateReceived, Name, EstimatedTaxImpacts, " & _
"EstimatedAssessedValue, GSReview, StatuteId, " & _
"StatuteRequirementsMet FROM Annexations " & _
"WHERE AnnexationId = " & annexationId.ToString()
annexs.SelectCommand = New SqlCommand(sql)
annexs.SelectCommand.CommandType = CommandType.Text
annexs.SelectCommand.Connection = Adapter.Connection

Dim ds As DataSet = New DataSet
annexs.UpdateCommand = New SqlCommand( _
"UPDATE Annexations SET DateReceived = @dateReceived, Name = @name,
EstimatedTaxImpacts = " & _
"@estimatedTaxImpacts, EstimatedAssessedValue = @estimatedAssessedValue,
" & _
"GSReview = @gsReview, StatuteId = @statuteId, StatuteRequirementsMet =
" & _
"@statuteRequirementsMet WHERE AnnexationId = " & annexationId,
Adapter.Connection)
annexs.UpdateCommand.Parameters.Add("@dateReceived ", SqlDbType.DateTime)
annexs.UpdateCommand.Parameters.Add("@name", SqlDbType.VarChar, 25)
annexs.UpdateCommand.Parameters.Add("@estimatedTax Impacts",
SqlDbType.Decimal)
annexs.UpdateCommand.Parameters.Add("@estimatedAss essedValue",
SqlDbType.Decimal)
annexs.UpdateCommand.Parameters.Add("@gsReview", SqlDbType.DateTime)
annexs.UpdateCommand.Parameters.Add("@statuteId", SqlDbType.Int)
annexs.UpdateCommand.Parameters.Add("@statuteRequi rementsMet",
SqlDbType.Bit)
annexs.Fill(ds, "Annexations")
Dim annex As DataRow
If ds.Tables(0).Rows.Count 0 Then
annex = ds.Tables(0).Rows(0)
Else
Return False
End If
If dateReceived.HasValue Then
annexs.UpdateCommand.Parameters("@dateReceived").V alue =
dateReceived.Value
End If
With annex
annexs.UpdateCommand.Parameters("@name").Value = name
If Not estimatedTaxImpacts.HasValue Then
annexs.UpdateCommand.Parameters("@estimatedTaxImpa cts").Value =
DBNull.Value
Else
annexs.UpdateCommand.Parameters("@estimatedTaxImpa cts").Value =
estimatedTaxImpacts.Value
End If
If Not estimatedAssessedValue.HasValue Then
annexs.UpdateCommand.Parameters("@estimatedAssesse dValue").Value =
DBNull.Value
Else
annexs.UpdateCommand.Parameters("@estimatedAssesse dValue").Value =
estimatedAssessedValue.Value
End If
If gsReview.HasValue Then
annexs.UpdateCommand.Parameters("@gsReview").Value = gsReview.Value
Else
annexs.UpdateCommand.Parameters("@gsReview").Value = DBNull.Value
End If
annexs.UpdateCommand.Parameters("@statuteId").Valu e = statuteId.Value
annexs.UpdateCommand.Parameters("@statuteRequireme ntsMet").Value =
statuteRequirementsMet
End With
Dim affectedrows As Integer = annexs.Update(ds, "Annexations")
Mar 16 '07 #1
0 1209

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

Similar topics

0
by: stumpman | last post by:
I have been using VB.NET for 2 years and have completed many applications. Recently I have experienced problems using the dataset designer and at this point I cannot use it at all. It began when...
0
by: Tom Gao | last post by:
Hello, We are having a recurring problem of a typed dataset that we have in a form dissapearing from the VS designer and all bindings being lost. The dataset is defined in another component and...
7
by: Martin Hazell | last post by:
I have had a form within a project that has been tested and working for the past 4-5 months. The other day, I decided to change all of my database connection strings into a dynamic property for a...
3
by: Mae | last post by:
Dear All, I have a problem here, I'm using C# Webform calling a webservices. The webservices return me a XMLnode, using this XMLnode I want to convert it to dataset so I can bind to the...
4
by: Dave Taylor | last post by:
I've been using the dataset designer in Visual Studio to create typed datasets for my application by dragging over tables from the Server Explorer and dropping them into the designer. The problem...
7
by: SteveT | last post by:
Can someone point me in the right direction? Somewhere I read that you reference a strongly typed dataset as if it were a class structure. For example, <SomeTests> <TestsGroups> <Group>...
4
by: Matt F | last post by:
I have an application that utilizes a dataset. I've found just today, that if the regional language settings are changed at the point of where I instantiate the DataSet an error is thrown of:...
2
by: Magnus Bergh | last post by:
I got a weird problem with designer. I have created a spearate assembly (DLL) containing my dataset classes and other classes which are shared bewteen the projects in the solution. When I try to...
2
by: Computer Guru | last post by:
I imported an Access database, created a dataset, added a bindingsource; and have been happily coding away - couldn't be easier. My problems started when I added a column to the database - I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.