Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2003
    Posts
    18

    Arrow Unanswered: opening url in a recordset

    I have two file a.asp and b.rst. Both the files residing on same server. The file b.rst contains the records from database.
    I want to open the b.rst file using recordset object. For that i wrote the following code in a.asp file.
    <%set rs=server.createobject("ADODB.recordset")
    rs.open "http://www.myserver.com/b.rst"
    while not rs.EOF
    response.write(rs("id") & "&nbsp;" & rs("name") & "<br>")
    rs.MoveNext
    wend
    %>
    This works fine. But it gives error when the two files are on different server.
    Can I open the b.rst file if it is on different server than a.asp

    I mean can we access a file residing on different server using a file on another server using the above code or any changes are needed in the above code or it is not possible at all?

    Thanks
    Rahul

  2. #2
    Join Date
    Jan 2003
    Posts
    23

    Re: opening url in a recordset

    I'm not sure why you would ever want to do this i assume you are using a db that does not support outside access. sounds like a IWAM account issue. please post the code on both pages so we can review.

  3. #3
    Join Date
    Feb 2003
    Posts
    18
    This is the first file which captures all the records from database table into the a .rst file. This is hosted on one server.
    <%set con=server.createobject("ADODB.connection")
    con.open "DSN=dsnname;UID=uid;PWD=pwd;"
    set rs=server.createobject("ADODB.recordset")
    rs.cursorlocation=adUseClient
    rs.cursorType=adOpenStatic
    rs.LockType=adLockBatchOptimistic
    rs.open "select * from myTable" , con
    rs.save "c:/try/myfile.rst", adPersistXML
    set rs = nothing
    %>

    The second file hosted on different server accesses all the records from the .rst file and displays them.
    <%set rs=server.createobject("ADODB.recordset")
    rs.open "c:/try/myfile.rst"
    'For web address it will be
    'rs.open "http://www.myfirstserver.com"
    while not rs.EOF
    response.write(rs("id") & "&nbsp;" & rs("name") & "<br>")
    rs.MoveNext
    wend
    %>


    I know accessing the data from different server is possible through xml but this method works when both files are on same server.
    Problem arises only for two different servers.

  4. #4
    Join Date
    Jul 2002
    Location
    Australia
    Posts
    147
    You can't *open* a recordset from another file. You have to actually run that file itself. Once it finishes running, the recordset doesn't exist anymore.

    The only thing you could try would be to Server.Execute the file which is basically a way of including the file.

    Cheers,
    Andrew
    There have been many posts made throughout the world.
    This was one of them.

  5. #5
    Join Date
    Jan 2003
    Posts
    23
    You are missing the point andrew he is saving it in a parseable file. Not returning the connection or record set. the rst file does not contain the connection or recordset it contains the product of calling the file.

  6. #6
    Join Date
    Jan 2003
    Posts
    23
    Is the location of that file a local share? you would have to give everyone complete acces of the file in order for the server to see it also you would not want to use a https:// the ip and file share name is what you would want to pass. This mabye off the subject but the results you are looking for might be easly resolved with a web service.

  7. #7
    Join Date
    Feb 2003
    Posts
    18
    Ok. I think sharing may be problem. That file may not have proper sharing given, so it is not running from another server.

    Thanks to all for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •