Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Dataset Designer problems

Reply
Thread Tools

Dataset Designer problems

 
 
SAL
Guest
Posts: n/a
 
      03-16-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("@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")


 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Designer Property Serialization -- Sycning inner properties to designer property window Alexander Higgins ASP .Net Building Controls 3 07-30-2007 09:09 PM
Designer Property Serialization -- Sycning inner properties to designer property window Alexander Higgins ASP .Net Web Controls 0 07-21-2007 12:58 AM
Sharepoint Designer/ Expression Web Designer : adding item in toolbox ? Steve B. ASP .Net 4 06-01-2007 04:29 AM
Dataset designer and multiple resultsets from stored proc John Dalberg ASP .Net 0 03-23-2006 11:02 PM
How to update dataset from database automatically via Visual Data Designer GS ASP .Net 1 01-19-2006 03:02 PM



Advertisments