J
John Cobb
Front end is passing in a string array of "types" of items to be retrieved.
I loop through array setting parameter and executing stored procedure to
populate a dataset but have had no luck combining all the rows into one
table. I've tried several variations of the below code and receive an "row
already belongs to a table." error. Help!
'Loop through types
For intLoop = 0 To Type.GetUpperBound(0)
' Execute query
spParms(0) = New SqlParameter("@Type", Type(intLoop))
spParms(0).Direction = ParameterDirection.Input
dsItems = SqlHelper.ExecuteDataset("dev.dbo.GetItemList",
spParms)
' add rows to dataset which will be returned
With dsItems.Tables(0)
'copy the table structure to the empty dataset which
will be returned
If dsReturn.Tables.Count = 0 Then
dsReturn.Tables.Add(dsItems.Tables(0).Clone)
End If
If .Rows.Count > 0 Then
For intX = 0 To .Rows.Count - 1
Dim myRow As DataRow = .Rows(intX)
.Rows(intX).Delete()
dsReturn.Tables(0).Rows.Add(myRow)
Next
End If
End With
Next
Thanks in advance for any help.
John
I loop through array setting parameter and executing stored procedure to
populate a dataset but have had no luck combining all the rows into one
table. I've tried several variations of the below code and receive an "row
already belongs to a table." error. Help!
'Loop through types
For intLoop = 0 To Type.GetUpperBound(0)
' Execute query
spParms(0) = New SqlParameter("@Type", Type(intLoop))
spParms(0).Direction = ParameterDirection.Input
dsItems = SqlHelper.ExecuteDataset("dev.dbo.GetItemList",
spParms)
' add rows to dataset which will be returned
With dsItems.Tables(0)
'copy the table structure to the empty dataset which
will be returned
If dsReturn.Tables.Count = 0 Then
dsReturn.Tables.Add(dsItems.Tables(0).Clone)
End If
If .Rows.Count > 0 Then
For intX = 0 To .Rows.Count - 1
Dim myRow As DataRow = .Rows(intX)
.Rows(intX).Delete()
dsReturn.Tables(0).Rows.Add(myRow)
Next
End If
End With
Next
Thanks in advance for any help.
John