Hi All,
Many moons ago I wrote a blog entry (http://blogs.conchango.com/jamiethomson/archive/2005/02/08/960.aspx) about how to, in a script task, iterate over a recordset that is populated into a variable using the Recordset destination.
My method there was to use ADODB.DLL but that's a bit "old school". Is there anything in System.Data to which I can cast the Object variable that will allow me to navigate the recordset stored within it
If there isn't, can someone tell me where all the ADODB objects now reside because ADODB.DLL doesn't exist in 2.0 Framework RTM.
Thanks
Jamie

How to iterate over a recordset?
Michael Stapleton
http://blogs.conchango.com/jamiethomson/archive/2006/01/04/2540.aspx
BigFive
Maybe I'm missing something, but, why not use the ForEach loop
K
waltc
Incidentally, this method would be useful in solving the problem I have outlined here - http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx feedbackid=79c74cef-3a4e-4dfe-8adc-784338ea4d7e where a raw file source and a datareader destination cannot co-exist.
-Jamie
frW
Dim olead As New Data.OleDb.OleDbDataAdapter
Dim dt As New Data.DataTable
olead.Fill(dt, Dts.Variables("rstDates").Value)
MsgBox("DataTable rowcount: " & dt.Rows.Count)
You can then iterate through DataTable version of the Recordset object.
Larry
Sadagopan Rajaram
Well...iterate over it in the script component in order to process it!. So, yes.
Peter Högström
I'm assuming you are trying to iterate over a recordset object created from the recordset destination. The object type of the recordset ends up being a COM object, so it is in fact using ADO and not ADO.NET.
I haven't tried casting the recordset to a ADO.Net object and I wouldn't expect the v2.0 framework to include any references to COM objects.
I did come up with a method to create/use an Interop Assembly of the ADO library (msado15.dll) to loop through the recordset. I have a suspicion that the ADODB.dll was really an Interop Assembly, so this method just recreates ADODB.dll. The nice thing about this method, is that you should be able to use the same methodology to import other COM libraries.
- Create Public/Private key pair.
- c:\Program Files\Microsoft Visual Studio 8\VC>sn -k keyPair.snk
- Create Interop DLL based on Strong Name pair
- c:\Program Files\Microsoft Visual Studio 8\VC>tlbimp
"c:\Program Files\Common Files\System\ado\msado15.dll" /out:
c:\windows\Microsoft.NET\Framework\v2.0.50727\
- Gac the Interop Assembly
- c:\Program Files\Microsoft Visual Studio 8\VC>gacutil /i "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Interop.ADODB.dll
- In Script Task, add a reference to the Interop DLL
- Script Task Code
- Dim rs As ADODB.Recordset
It may still be possible to cast the recordset object to a .Net object, which I will still research. This method does require MDAC, but most versions of Windows come with it standard.Interop.ADODB.dll /keyfile: keypair.snk /namespace:ADODB
rs = CType(Dts.Variables("rstDates").Value, ADODB.Recordset)
While Not rs.EOF
'MsgBox(rs("DateKey").Value)
rs.MoveNext()
End While
Larry
Musa-1
Blimey. I didn't think I'd have to jump thru those sorts of hoops.
Keep me posted if you find anything in .net that will do the job.
Thanks Larry!
-Jamie
marcooq
I don't typically think of consuming data in the dataflow as iterating, but yeah, semantics. Sorry.
It's funny you bring this up cuz I was just thinking about how to do the same thing actually.
We're in mind sync. :)
K
SJWhiteley
I got the basis of the conversion from the following pdf from microsoft.
http://msdn.microsoft.com/vbrun/staythepath/
Larry
Teddydino
Larry,
You are THE MAN. That works a treat.
Would you mind if I posted this up on my blog I'll credit you of course!
-Jamie
Geert Verhoeven
You say toe-maydo, I say tamarto!!!! :)
Akhil Jindal 007
Wait till you see the blog post - all will become clear ;)
Azzer
Oh, you want to process the recordset, not iterate over it. Yeah, gotcha.
K