|
 |
asp_database_setup thread: Connectionless recordset in VBScript
Message #1 by "Ian Montgomery" <montgomeryi@y...> on Mon, 26 Mar 2001 16:15:09
|
|
Hi, all.
I need to combine two recordsets from a database. I thought I'd dynamically create a connectionless rs based on the field names
from the other two rs'. I'm having trouble creating the connectionless rs. I get an error on the .append or the .open depending on
which I place first. Every example I can find shows the .append coming first. Please, take a look at the code and make
suggestions.
Thank you.
--Ian
dim objRSThree = Server.CreateObject("ADODB.Recordset")
objRSThree.cursorlocation = adUseClient
for each strField in objRSOne.Fields
objRSThree.Fields.Append Char strField.Name, strField.Type, strField.DefinedSize
next
for each strField in objRSTwo.Fields
objRSThree.Fields.Append strField.Name, strField.Type, strField.DefinedSize
next
objRSThree.Open ,,adOpenStatic, adLockBatchOptimistic
Message #2 by "Ken Schaefer" <ken@a...> on Tue, 27 Mar 2001 18:08:15 +1000
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: I need to combine two recordsets from a database.
: I thought I'd dynamically create a connectionless rs based
:on the field names from the other two rs'. I'm having trouble
: creating the connectionless rs. I get an error on the .append
: or the .open depending on which I place first. Every example
: I can find shows the .append coming first. Please, take a look
: at the code and make suggestions.
:
: Thank you.
: --Ian
:
: dim objRSThree = Server.CreateObject("ADODB.Recordset")
: objRSThree.cursorlocation = adUseClient
: for each strField in objRSOne.Fields
: objRSThree.Fields.Append Char strField.Name, strField.Type,
strField.DefinedSize
: next
: for each strField in objRSTwo.Fields
: objRSThree.Fields.Append strField.Name, strField.Type,
strField.DefinedSize
: next
: objRSThree.Open ,,adOpenStatic, adLockBatchOptimistic
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You .append before you .open
Can you post the error you are getting?
Cheers
Ken
Message #3 by Ian Montgomery <montgomeryi@y...> on Tue, 27 Mar 2001 06:36:34 -0800 (PST)
|
|
Here's the error. I believe it has something to do with the recordset having
to be open first. This is possible then? I can create an empty recordset
without a connection, right?
Error Type:
Microsoft VBScript runtime (0x800A0E78)
Unknown runtime error
Thank you,
--Ian
--- Ken Schaefer <ken@a...> wrote:
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> : I need to combine two recordsets from a database.
> : I thought I'd dynamically create a connectionless rs based
> :on the field names from the other two rs'. I'm having trouble
> : creating the connectionless rs. I get an error on the .append
> : or the .open depending on which I place first. Every example
> : I can find shows the .append coming first. Please, take a look
> : at the code and make suggestions.
> :
> : Thank you.
> : --Ian
> :
> : dim objRSThree = Server.CreateObject("ADODB.Recordset")
> : objRSThree.cursorlocation = adUseClient
> : for each strField in objRSOne.Fields
> : objRSThree.Fields.Append Char strField.Name, strField.Type,
> strField.DefinedSize
> : next
> : for each strField in objRSTwo.Fields
> : objRSThree.Fields.Append strField.Name, strField.Type,
> strField.DefinedSize
> : next
> : objRSThree.Open ,,adOpenStatic, adLockBatchOptimistic
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> You .append before you .open
>
> Can you post the error you are getting?
>
> Cheers
> Ken
>
Message #4 by "Ken Schaefer" <ken@a...> on Wed, 28 Mar 2001 10:58:52 +1000
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: Here's the error. I believe it has something to do with the recordset
having
: to be open first. This is possible then? I can create an empty recordset
: without a connection, right?
:
: Error Type:
: Microsoft VBScript runtime (0x800A0E78)
: Unknown runtime error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It may be that when you are doing things like:
strField.Type
the output isn't one of the VBScript constants, hence the VBScript Runtime
Error.
What if you do this:
On Error Resume Next
For Each strField in objRSOne.Fields
Response.Write(strField.Name & " - ")
Response.Write(strField.Type & " - ")
Response.Write(strField.DefinedSize & "<br>" & vbCrLf)
Next
|
|
 |