pro_vb thread: Re: FW: Function returns recordset...
i already did it but... the same result
-----Original Message-----
From: Zulfazli [mailto:Zulfazli@l...]
Sent: Thursday, May 02, 2002 1:21 PM
To: professional vb
Subject: [pro_vb] RE: Function returns recordset...
Cause the connection is already close. Try to define the connection outside
returnrs, example, in declaration section, and use it in the returnrs.
> -----Original Message-----
> From: George Theodorakopoulos [SMTP:gtheo@b...]
> Sent: Thursday, May 02, 2002 5:11 PM
> To: professional vb
> Subject: [pro_vb] Function returns recordset...
>
> Hello..
> I use the following code ...
> i call a function that returns a recordset from sub "AAA" but i could not
> access the data that returned from the function....
> what goes wrong with the code???
>
> Thanx!!!
>
>
>
> Private Function returnrs() As ADODB.Recordset
>
> Dim rs As ADODB.Recordset
> Dim cn As ADODB.Connection
>
> Set cn = New ADODB.Connection
> cn.ConnectionString = "Provider=SQLOLEDB.1;Integrated
> Security=SSPI;Persist Security Info=False;User ID=ggggghjgh;Initial
> Catalog=Northwind;Data Source=MYSERVER"
> cn.Open
>
> Set rs = New ADODB.Recordset
> rs.Open "Select * from tblusers", cn
> Set rets = rs
>
>
> rs.Close
> Set rs = Nothing
> cn.Close
> Set cn = Nothing
>
> End Function
>
> Private Sub AAA
> Dim rs1 As ADODB.Recordset
>
> Set rs1 = New ADODB.Recordset
> Set rs1 = retrs
> L1.Clear
> While Not rs1.EOF
> Listbox1.AddItem rs1.Fields(3)
> retrs.MoveNext
> Wend
>
> Set rs1 = Nothing
> End Sub
> ---