PC Review


Reply
Thread Tools Rate Thread

Dataset Designer problems

 
 
SAL
Guest
Posts: n/a
 
      16th Mar 2007
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("@estimatedTaxImpacts",
SqlDbType.Decimal)
annexs.UpdateCommand.Parameters.Add("@estimatedAssessedValue",
SqlDbType.Decimal)
annexs.UpdateCommand.Parameters.Add("@gsReview", SqlDbType.DateTime)
annexs.UpdateCommand.Parameters.Add("@statuteId", SqlDbType.Int)
annexs.UpdateCommand.Parameters.Add("@statuteRequirementsMet",
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").Value =
dateReceived.Value
End If
With annex
annexs.UpdateCommand.Parameters("@name").Value = name
If Not estimatedTaxImpacts.HasValue Then
annexs.UpdateCommand.Parameters("@estimatedTaxImpacts").Value =
DBNull.Value
Else
annexs.UpdateCommand.Parameters("@estimatedTaxImpacts").Value =
estimatedTaxImpacts.Value
End If
If Not estimatedAssessedValue.HasValue Then
annexs.UpdateCommand.Parameters("@estimatedAssessedValue").Value =
DBNull.Value
Else
annexs.UpdateCommand.Parameters("@estimatedAssessedValue").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").Value = statuteId.Value
annexs.UpdateCommand.Parameters("@statuteRequirementsMet").Value =
statuteRequirementsMet
End With
Dim affectedrows As Integer = annexs.Update(ds, "Annexations")


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Studio DataSet designer doesn't regenerate designer.cs code Barney Microsoft C# .NET 3 15th Oct 2007 04:15 PM
Problems opening forms in designer when dataset is defined in another assembly Magnus Bergh Microsoft Dot NET 2 15th Jun 2007 03:07 PM
DataSet Designer/adding multiple tables to a dataset/ how? =?Utf-8?B?Q3VydGlz?= Microsoft ADO .NET 1 21st Aug 2006 02:09 PM
Component Designer like DataSet Designer? Mark Olbert Microsoft Dot NET Framework Forms 0 18th May 2004 06:21 PM
Problem updating existing typed dataset from Generate Dataset designer Eric Kennedy Microsoft ADO .NET 0 29th Aug 2003 05:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:58 AM.