I executed the following code:
' Return the contents of the WordCounts collection to SQL
Server as a rowset
' Define the row to be sent to SQL Server
Dim smdMetaData(2) As SqlMetaData
smdMetaData(0) = New SqlMetaData("vcWord",
SqlDbType.VarChar, 100)
smdMetaData(1) = New SqlMetaData("cnt", SqlDbType.BigInt)
smdMetaData(2) = New SqlMetaData("SourceFn",
SqlDbType.VarChar, 1000)
Dim sqlRec As New SqlDataRecord(smdMetaData)
' Initialize the pipe stream
SqlContext.Pipe.SendResultsStart(sqlRec) '
Initialize sending the rowset
Dim sintTotal As SqlInt64
' Return each count result returned from the CHARINDEX query
For Each wc As WordCount In WordCounts
' Populate the row columns
sqlRec.SetSqlString(0, wc.strWord) ' Set the
individual SqlRecord values
sqlRec.SetSqlInt64(1, wc.intCnt)
sqlRec.SetSqlString(0, wc.strSourceFilename)
SqlContext.Pipe.Send(sqlRec) ' Send one row for each
word processed
sintTotal += wc.intCnt
Next
SqlContext.Pipe.SendResultsEnd() ' Finalize sending the
rowset
but I get "A Result set is currently being sent to the pipe. End the current
result set before calling Send" the first time the SqlContext.Pipe.Send is
called.
If I remove the SendResultStart and SendResultsEnd the code runs, but I get
1 resultset for each row.
Is the only way to send a multiple rowset resultset to use a DataReader?
TIA
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
|