ADO, XML and ASP

H

harvinder singh

Hi
I am trying to get the XML out of my Microsoft Access database, I am
able to get the records from the database however not in the XML format.
below is the ASP code for the same. What could be the problem.

<%@ language=JScript %>
<%
Response.ContentType = "text/xml"

var lobjXMLData = Server.CreateObject("Microsoft.XMLDOM")
lobjXMLData.async = false

var pobjRecordset = Server.CreateObject("ADODB.Recordset");
var sSQL , sConn;

sSQL = "SELECT * FROM Employee"
sConn= "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\\SRR\\SRR.mdb"

pobjRecordset.Open(sSQL, sConn);

// This commented code works.
/* pobjRecordset.MoveFirst();
while (pobjRecordset.EOF != true)
{
Response.Write(pobjRecordset("EmpId")+pobjRecordset("Name")+"<br>");
pobjRecordset.MoveNext();
}
*/

Response.Write("<?xml version='1.0' encoding='windows-1252' ?>")

pobjRecordset.save(lobjXMLData, pobjRecordset.adPersistXML)

Response.Write(lobjXMLData.xml);
Response.Write(lobjXMLData.hasChildNodes);
%>

The output that comes is "False"


Regards
Harvinder Singh
 
B

Bob Barrows [MVP]

harvinder said:
Response.Write("<?xml version='1.0' encoding='windows-1252' ?>")

This will not work. The Save method will only use utf-8. This will be
ignored.
pobjRecordset.save(lobjXMLData, pobjRecordset.adPersistXML)

Where did you get this syntax? "adPersistXML" is a constant defined in the
ADO Type Library. It is not a property of the recordset object.

I assume you are trying to transfer a recordset to the client, Here is a
demo showing how to do it:
http://www.davidpenton.com/testsite/tips/

Hmm, I just tested the link and got a "server not found" message. I've
notified the site's owner.

Bob Barrows
 
H

harvinder singh

Thanks bob,
I have changed the code ...
Removed the "Response.Write("<?xml version='1.0' encoding='windows-1252'
?>")"

and also using 1 instead of "pobjRecordset.adPersistXML"
i.e. pobjRecordset.save(lobjXMLData, 1)
but surpriseingly it was not giving me any error


thanks
harvinder
 

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

Forum statistics

Threads
474,149
Messages
2,570,842
Members
47,388
Latest member
EarthaGilm

Latest Threads

Top