Ask a Question related to ASP Database, Design and Development.
-
harvinder singh #1
ADO, XML and ASP
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")+pobjRecordse t("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
harvinder singh Guest
-
Bob Barrows [MVP] #2
Re: ADO, XML and ASP
harvinder singh wrote:
This will not work. The Save method will only use utf-8. This will be> Response.Write("<?xml version='1.0' encoding='windows-1252' ?>")
ignored.
Where did you get this syntax? "adPersistXML" is a constant defined in the>
> pobjRecordset.save(lobjXMLData, pobjRecordset.adPersistXML)
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:
[url]http://www.davidpenton.com/testsite/tips/[/url]
Hmm, I just tested the link and got a "server not found" message. I've
notified the site's owner.
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Bob Barrows [MVP] Guest
-
harvinder singh #3
Re: ADO, XML and ASP
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
"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:eP8TswnOEHA.268@TK2MSFTNGP11.phx.gbl...> harvinder singh wrote:
>>> > 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:
> [url]http://www.davidpenton.com/testsite/tips/[/url]
>
> Hmm, I just tested the link and got a "server not found" message. I've
> notified the site's owner.
>
> Bob Barrows
>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>
>
harvinder singh Guest



Reply With Quote

