Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Recordset Object as a Parameter

Status
Not open for further replies.

ufobaby

MIS
Sep 25, 2001
238
US
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 & &quot;<option>&quot; & rsCombo(lngFld) & &quot;</option>&quot; & 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 &quot;test.asp&quot;
<!-- #include file=&quot;globedump.asp&quot; -->

Set Conn = Server.CreateObject(&quot;adodb.connection&quot;)
Set rsGlobe = Server.CreateObject(&quot;adodb.recordset&quot;)

Conn.Open (.....

rsGlobe.Open (.....

'//// This Recordset &quot;rsGlobe&quot; should be passed as a parameter to the &quot;FillCombo&quot; function

strResult = FillCombo(rsGlobe,0)

'=============================================================

This keeps giving error regarding some invalid object. If i use &quot;ByRef&quot; instead of &quot;ByVal&quot; 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]
Niraj [noevil]
 
if your code above is your actual code, i think you misspelled the while word in the FillCombo function. this may be the one being pointed to by the error. Also, try removing the vbCrLf. this will add a new line on every option on your combo box.
 
hey thanks for the response

and sorry for this.

the problem was with the SQL, i rectified the same

[cheers]
Niraj [noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top