Click here to Skip to main content
15,896,557 members
Articles / Desktop Programming / MFC

Access database using XML without SQL-XML

Rate me:
Please Sign up or sign in to vote.
3.33/5 (3 votes)
25 Apr 20022 min read 75.6K   1.1K   24  
How to access RDBMS liks MS SQL or Orcale using XML. The core part using COM technology and ATL.
<!--TOOLBAR_START--> <!--TOOLBAR_EXEMPT--> <!--TOOLBAR_END-->
<%@ language=javascript %>
<% 

    Response.Expires = -1000;
    if (Request.ServerVariables("REQUEST_METHOD") == "POST") 
    {

	var xmlise ,xmlstr,reason_str,doc;
	xmlise = Server.CreateObject ("DataEngine.DEng");
	//xmlise = Server.CreateObject("DataEngine.DEng");
	xmlise.ConnectionString = "PROVIDER=SQLOLEDB;DataSource=XMZY;Initial Catalog=pubs";
	//xmlise.ConnectionString ="PROVIDER=SQLOLEDB;DataSource=XMZY";
	xmlise.User  ="SA";
	xmlise.Password ="";
	
	reason_str ="<pcommand>reptq1</pcommand>";
	//xmlstr =xmlise.IsServerOK();
	xmlstr =xmlise.GetData (reason_str);
	//xmlstr= xmlise.GetCatalogs ();
	//xmlstr=xmlise.GetColumns ("authors");

	//xmlstr=xmlise.GetProcedures ();
	//xmlstr=xmlise.GetData (reason_str);

       // Load the posted XML document
    //xmlstr="<test>abcd</test>";
    doc = Server.CreateObject("Microsoft.XMLDOM");
    doc.load(xmlstr);
	doc.loadXML(xmlstr);
	
      // and ping it right back to the client.
	
    Response.ContentType = "text/xml";
    doc.save(Response);
    xmlise = null;
   
	//Response.Write xmlstr;
    }
    else
    {
      var strPOSTURL = "http://" + Request.ServerVariables("SERVER_NAME") +
        Request.ServerVariables("SCRIPT_NAME");
%>
<html>
	<script language="javascript">

  function postXML()
  {    
    var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.Open("POST", "<%=strPOSTURL%>", false);
    //alert(XML.value );
    xmlhttp.Send(XML.value);
    //alert("Round tripped XML document:\n\n"+xmlhttp.response);
    //alert("Round tripped XML document:\n\n" + xmlhttp.responseXML.xml);
    XML.innerText=xmlhttp.responseXML.xml;
    //XML.innerText = xmlhttp.response;
  }
	</script>
	<textarea id="XML" rows="12" cols="60"><XML>
This is the XML document that will be round tripped...
</XML></textarea>
	<P>
		<input type="button" value="PING" onclick="postXML()"></P>
	<P>The source of the ASP script is:</P>
</html>
<%
    }
%>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
China China
I'm write program from 1990. My research field is CAG,CAD and Image processing. I select C/C++, ASP, Java, XML as my usaully developing tools. Occasional , write code in Delphi and VB. I'm using Visual C++ from 1996. If you have anything unclear, e-mail to :zhou_cn123@sina.com Software Engineering and CAD is my mainly research program.

You also can reach me on msn: zhoujohnson@hotmail.com

Comments and Discussions