468,771 Members | 1,923 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,771 developers. It's quick & easy.

Dataset Designer problems

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,
annexs.UpdateCommand.Parameters.Add("@dateReceived ", SqlDbType.DateTime)
annexs.UpdateCommand.Parameters.Add("@name", SqlDbType.VarChar, 25)
annexs.UpdateCommand.Parameters.Add("@estimatedTax Impacts",
annexs.UpdateCommand.Parameters.Add("@estimatedAss essedValue",
annexs.UpdateCommand.Parameters.Add("@gsReview", SqlDbType.DateTime)
annexs.UpdateCommand.Parameters.Add("@statuteId", SqlDbType.Int)
annexs.UpdateCommand.Parameters.Add("@statuteRequi rementsMet",
annexs.Fill(ds, "Annexations")
Dim annex As DataRow
If ds.Tables(0).Rows.Count 0 Then
annex = ds.Tables(0).Rows(0)
Return False
End If
If dateReceived.HasValue Then
annexs.UpdateCommand.Parameters("@dateReceived").V alue =
End If
With annex
annexs.UpdateCommand.Parameters("@name").Value = name
If Not estimatedTaxImpacts.HasValue Then
annexs.UpdateCommand.Parameters("@estimatedTaxImpa cts").Value =
annexs.UpdateCommand.Parameters("@estimatedTaxImpa cts").Value =
End If
If Not estimatedAssessedValue.HasValue Then
annexs.UpdateCommand.Parameters("@estimatedAssesse dValue").Value =
annexs.UpdateCommand.Parameters("@estimatedAssesse dValue").Value =
End If
If gsReview.HasValue Then
annexs.UpdateCommand.Parameters("@gsReview").Value = gsReview.Value
annexs.UpdateCommand.Parameters("@gsReview").Value = DBNull.Value
End If
annexs.UpdateCommand.Parameters("@statuteId").Valu e = statuteId.Value
annexs.UpdateCommand.Parameters("@statuteRequireme ntsMet").Value =
End With
Dim affectedrows As Integer = annexs.Update(ds, "Annexations")
Mar 16 '07 #1
0 1073

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by stumpman | last post: by
7 posts views Thread by Martin Hazell | last post: by
4 posts views Thread by Dave Taylor | last post: by
7 posts views Thread by SteveT | last post: by
4 posts views Thread by Matt F | last post: by
2 posts views Thread by Computer Guru | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.