1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

ADO save Recordset XML HELP!

Discussion in 'C#' started by bilfwebb, Nov 25, 2005.

  1. #1
    I have a sample ASP script that will open an Access db, run a SQL query, and use the save feature of the ADODB recordset to the response buffer (to display it on screen):

    oRS.Save Response, adPersistXML

    This is the standard way I have seen on most ADO Save examples.

    I made this script at work, and it functions as expected. An example of the results from the script:
    <s:Schema id="RowsetSchema">
    <s:ElementType name="row" content="eltOnly">
    <s:AttributeType name="ID" rs:number="1" rs:maydefer="true" rs:writeunknown="true">
    <s:datatype dt:type="int" dt:maxLength="4" rs:precision="10" rs:fixedlength="true"/>
    <s:AttributeType name="price_group_ID" rs:number="2" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
    <s:datatype dt:type="int" dt:maxLength="4" rs:precision="10" rs:fixedlength="true"/>

    Great stuff. However, I took the script home, and tried to run it on my XP PRO, and got an error. I loaded the script onto a hosting companies webserver, and got the same error. I loaded the script onto a 2nd and 3rd webserver, and got the same error.

    The error is :

    XML Parsing Error: not well-formed
    TG! (with some squares before the TG)

    When I view the source (Only works in Firefox, IE says no source) I get:
    etc etc etc.

    Now this is the same script, using the same database. It works on
    1) my work server. Windows 2000 server.

    It doesnt work on

    1) XP PRO SP2, IIS 5.1

    2) Windows 2000 server (hosting company 1)

    3) Windows 2000 server (hosting company 2)

    4) Windows 2003 server (Hosting compoany 3)

    Can anyone help shed some light on this? I am running lates version of MDAC at home, and all service patches. I ran MS Component checker, and it says all is installed ok. Below is the code.

    Why does it work at work but on no other server? All the examples on the web show the Save method working fine, and am stumped. I have googled but cant find anything.

    Please can anyone help?

    dim objConn
    dim oRS
    dim connStr, sSQL
    sSQL = "select * from _storePriceGroupsMatrix"
    connStr = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & Server.MapPath("webData.mdb")


    Set objConn = Server.CreateObject("ADODB.Connection")
    Set oRS = Server.CreateObject("ADODB.Recordset")
    objConn.open connStr

    Set oRS.ActiveConnection = objConn
    oRS.Open sSQL
    oRS.Save Response, adPersistXML

    If oRS.STATE = adStateOpen Then oRS.Close
    If objConn.STATE = adStateOpen Then objConn.Close
    Set oRS = Nothing
    Set objConn = Nothing %>
    bilfwebb, Nov 25, 2005 IP
  2. bilfwebb

    bilfwebb Guest

    Likes Received:
    Best Answers:
    Trophy Points:
    Error Code: -1072896760
    Error Reason: An invalid character was found in text content.
    Error Line: 1
    Browser ASP Response buffer ERROR
    XML Parsing Error: not well-formed
    Location: http://localhost/ado/defaultserver.asp
    Line Number 1, Column 1:TG!

    So I am guessing that the ADODB.Recordset object isnt writing XML?

    I changed the save option from AdPersistXML to ADPersistATDG (The only 2 options). The output is the same for both., both 5.77 KB (5,911 bytes), and give the same error message in the browser.

    I saved each recordset to file. When I tried to load either file saved (ADPersistATDG or ADPersistXML), the script stops at the line loading the file (even with ON ERROR RESUME NEXT)

    I tried the same using ADODB.Stream's, with asp example code from MSDN. When I save a stream to the response buffer, or file, I get exactly the same result as saving a Recordset. Same file, same contents.

    I have also tried this with the Northwind Access database (downloaded from Microsoft), in case my db was corrupt. Same results. Tried with Access 98 and 2000 db's too.

    So on 4 seperate servers (different MS OS's, locations) I am getting the same results.

    But on my work server, it works fine.

    OK either something is wrong with my implementation of the ADODB object Save method (my scripts are from MSDN, and work on 1 server).

    Or something is up with the ADODB Save Method on these 4 servers? Maybe out of date MDAC?
    I downloaded MDAC and Microsoft Jet Analysis and Repair Utility, and have the latest Jet and MDAC libraries installed. (ADO is part of MDAC)

    Does anyone know why I always get the same output from the Save method, whatever I try? Its got to be something silly. Could you please try my original ASP code example and tell me what your ADODB outputs to the browser window?

    Edit/Delete Message
    bilfwebb, Nov 25, 2005 IP