hi all,
am trying to pass recordset obbject as parameter, to a function.
'==== Code in "globedump.asp"
Function FillCombo(Byval rsCombo,Byval lngFld)
'-- rsCombo = Recordset Object
'-- lngFld = Field # in the Recordset
rsCombo.MoveFirst
Do whil rsCombo.Eof = False
FillCombo = FillCombo & "<option>" & rsCombo(lngFld) & "</option>" & vbCrlf
rsCombo.MoveNext
Loop
End function
Ok, now this function is supposed to create a string which i'll use in the dropdown box.
'==== Code in the "test.asp"
<!-- #include file="globedump.asp" -->
Set Conn = Server.CreateObject("adodb.connection"
Set rsGlobe = Server.CreateObject("adodb.recordset"
Conn.Open (.....
rsGlobe.Open (.....
'//// This Recordset "rsGlobe" should be passed as a parameter to the "FillCombo" function
strResult = FillCombo(rsGlobe,0)
'=============================================================
This keeps giving error regarding some invalid object. If i use "ByRef" instead of "ByVal" for the recordset object it just doesnot work.
I know an alternative is to open a connection and recordset in the Globedump, pass SQL as string and close the connection and recordset. But am curious to know how to pass this object as a parameter.
![[cheers] [cheers] [cheers]](/data/assets/smilies/cheers.gif)
Niraj![[noevil] [noevil] [noevil]](/data/assets/smilies/noevil.gif)
am trying to pass recordset obbject as parameter, to a function.
'==== Code in "globedump.asp"
Function FillCombo(Byval rsCombo,Byval lngFld)
'-- rsCombo = Recordset Object
'-- lngFld = Field # in the Recordset
rsCombo.MoveFirst
Do whil rsCombo.Eof = False
FillCombo = FillCombo & "<option>" & rsCombo(lngFld) & "</option>" & vbCrlf
rsCombo.MoveNext
Loop
End function
Ok, now this function is supposed to create a string which i'll use in the dropdown box.
'==== Code in the "test.asp"
<!-- #include file="globedump.asp" -->
Set Conn = Server.CreateObject("adodb.connection"
Set rsGlobe = Server.CreateObject("adodb.recordset"
Conn.Open (.....
rsGlobe.Open (.....
'//// This Recordset "rsGlobe" should be passed as a parameter to the "FillCombo" function
strResult = FillCombo(rsGlobe,0)
'=============================================================
This keeps giving error regarding some invalid object. If i use "ByRef" instead of "ByVal" for the recordset object it just doesnot work.
I know an alternative is to open a connection and recordset in the Globedump, pass SQL as string and close the connection and recordset. But am curious to know how to pass this object as a parameter.
![[cheers] [cheers] [cheers]](/data/assets/smilies/cheers.gif)
Niraj
![[noevil] [noevil] [noevil]](/data/assets/smilies/noevil.gif)