Problem using VB to retrieve ASP/XML using ADO recordset

Problem using VB to retrieve ASP/XML using ADO recordset

Post by Kris Truyen » Wed, 22 Jan 2003 22:36:20



Hello,

I've read about ADO url recordset connections, but somehow can't get
this simple example working:

Dim strConnection               As String
Dim myRecordset                 As ADODB.Recordset

Set myRecordset = New ADODB.Recordset
myRecordset.Open "http://computercity.dyndns.org/test.xml", , _
                  adOpenStatic, adLockBatchOptimistic

myRecordset.Close
Set myRecordset = Nothing

The ASP referenced above is a simple XML file as follows:

<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tove</to>
<from>Jani</from>
</note>

When running the VB app, following error occurs on the myRecordset.Open
command line:

Run Time Error 3709 - The connection cannot be used to perform this
operation. It is either closed, invalid or incorrect.

I have tried opening an ADODB.connection first and inserting this one in
the recordset.open line, but no success.

Please help!!!

Regards,
Kris

 
 
 

1. Problem with retrieving an ADO Recordset from SQLServer using Temp Tables

I created a sample Stored Proc in SQLServer 2000 which Selects a field
from a "User" tabe and inserts it into a temporary table (#tmpUser):

CREATE  PROCEDURE [TestProc]
As
Select UserID as UserID into #tmpUser  from [User]
Select * from #tmpUser
GO

I test the procedure using SQL Query Analyzer and 15 records are show.

I then tried to excute the Proc from  VB which resulted in an error:
(Run Time error: 3704 'Operation is not allowed when the object is
closed')

If I remove the temp table in the stored procedure and do a simple
Slect statement (i.e. Select UserID from [User]), the VB code runs
fine.

Can anyone shed some light as to what the problem may be and how to
resolve this problem?

Thanks in advance.

'  ****** VB Code *******'

Private Sub Form_Load()

    Dim Cnn As Connection
    Dim rs As ADODB.Recordset
    Dim cmd As ADODB.Command

    Const CnString =
"PROVIDER=SQLOLEDB;SERVER=Dad_Desktop;UID=sa;PWD=;DATABASE=Friends;"

    Set Cnn = New ADODB.Connection
    Set rs = New ADODB.Recordset
    Set cmd = New ADODB.Command

    Cnn.Open CnString

    With rs
        .CursorLocation = adUseClient
        .CursorType = adOpenStatic
        .LockType = adLockReadOnly
    End With

    With cmd
        .ActiveConnection = Cnn
        .CommandType = adCmdStoredProc
        .CommandText = "TestProc"
    End With

    rs.Open cmd

    While Not rs.EOF
        Print rs(0)
        rs.MoveNext
    Wend

    Cnn.Close
    Set rs = Nothing
    Set cmd = Nothing
    Set Cnn = Nothing

End Sub

2. Not enough memory/Virtual memory error from large query

3. Newbie for External Procedures

4. Database Replication Available for FileMaker (SyncDeK 4.5)

5. SQL XML Stored Procedure using XML Explicit Returing XML to ASP Page

6. Round-robin select via Stored Procedure

7. Using FOR XML to retrieve data into VB

8. Retrieving XML from SQL Server 2000 using an ado connection object

9. Retrieving XML from ADO using XSL

10. retrieve datamodel in Access DB in ASP using ADO

11. Using an ADO stream to retrieve xml data from remote website