recordset name poblem

D

Dr.Gizmo

Hello!

How can I generate random recordset name in do while loop, every time
that loop pass my code. example:

do while something

Set dpconn1 = spoj.Execute("SELECT * FROM txt WHERE number = 1")
if not dpconn1.EOF then
Do while not dpconn1.EOF

...

dpconn1.movenext
loop
end if
dpconn1.Close
set dpconn1 = Nothing

loop

so I want that name dpconn1 is different in every loop, for example in
second run it should be called dpconn2, and like that until do while
is not over...

I need this, because I'm calling function inside that same function,
so there would be the same recordset name, example:

function a1()
Set dpconn1 = spoj.Execute("SELECT * FROM txt WHERE number = 1")
if not dpconn1.EOF then
Do while not dpconn1.EOF

'++++this is a1 inside a1
Set dpconn1 = spoj.Execute("SELECT * FROM txt WHERE number = 2")
if not dpconn1.EOF then
Do while not dpconn1.EOF

'next is a1 inside a1, which is inside original a1, and so...
...

dpconn1.movenext
loop
end if
dpconn1.Close
set dpconn1 = Nothing
'++++

dpconn1.movenext
loop
end if
dpconn1.Close
set dpconn1 = Nothing
end function

thanx!
:)
 
K

Ken Schaefer

Why are you doing what you are doing?

Cheers
Ken


: Hello!
:
: How can I generate random recordset name in do while loop, every time
: that loop pass my code. example:
:
: do while something
:
: Set dpconn1 = spoj.Execute("SELECT * FROM txt WHERE number = 1")
: if not dpconn1.EOF then
: Do while not dpconn1.EOF
:
: ...
:
: dpconn1.movenext
: loop
: end if
: dpconn1.Close
: set dpconn1 = Nothing
:
: loop
:
: so I want that name dpconn1 is different in every loop, for example in
: second run it should be called dpconn2, and like that until do while
: is not over...
:
: I need this, because I'm calling function inside that same function,
: so there would be the same recordset name, example:
:
: function a1()
: Set dpconn1 = spoj.Execute("SELECT * FROM txt WHERE number = 1")
: if not dpconn1.EOF then
: Do while not dpconn1.EOF
:
: '++++this is a1 inside a1
: Set dpconn1 = spoj.Execute("SELECT * FROM txt WHERE number = 2")
: if not dpconn1.EOF then
: Do while not dpconn1.EOF
:
: 'next is a1 inside a1, which is inside original a1, and so...
: ...
:
: dpconn1.movenext
: loop
: end if
: dpconn1.Close
: set dpconn1 = Nothing
: '++++
:
: dpconn1.movenext
: loop
: end if
: dpconn1.Close
: set dpconn1 = Nothing
: end function
:
: thanx!
: :)
 
D

Dr.Gizmo

Ken Schaefer said:
Why are you doing what you are doing?

Cheers
Ken

....because, I'm building category list (tree view), and every category
may have unlimited subcategories, and so on...

I could solve this easily with loop in loop (f.e. ten times), but then
I would be limited to 10 level subcats, an I need it to be unlimited,
which requires changing name of record set in every loop dynamicly.

There is solution in 'execute' command:

dpconn1 = "RS"
strng = "Set "&dpconn1&" = spoj.Execute(""SELECT * FROM txtWHERE nivo
= "&nivonext&" AND prekat = '"&prekatnext&"'"")" & vbCrLf
strng = strng & ...
execute strng

But this solution is complicated, and I was wondering is there any
easier solution?
 
D

dlbjr

there are many far easier ways!

recordset objects are high priced items in code. Just think of the
processing burn on the server when 100 or more users hit the sight at the
same time.

Ouch!

dlbjr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top