Previous Thread:   RETURN value from CLR SP

2/24/2006 1:31:42 PM    SqlContext.Pipe.Send
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.  
  
__________________________________



2/24/2006 1:47:42 PM    Re: SqlContext.Pipe.Send
"William \(Bill\) Vaughn" <billvaRemoveThis@nwlink.com> wrote in  
  
news:OvCJ1mYOGHA.3556@TK2MSFTNGP10.phx.gbl:  
  
Use SendReultsStart and SendResultsEnd, but instead of Send change that to  
  
SendResultsRow.  
  
Niels

2/24/2006 1:57:36 PM    Re: SqlContext.Pipe.Send
Thanks... I missed that. Now it works (slowly, but it works)... :)  
  
--  
  
____________________________________  
  
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.  
  
__________________________________  
  
"Niels Berglund" <nielsb@develop.com> wrote in message  
  
news:Xns9774DDB76F001nielsbdevelopcom@207.46.248.16...