Click here to Skip to main content
15,894,362 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.
// XMLGenerator.h: interface for the XMLGenerator class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_XMLGENERATOR_H__93788D78_DB54_4A37_B239_CBB0606D8960__INCLUDED_)
#define AFX_XMLGENERATOR_H__93788D78_DB54_4A37_B239_CBB0606D8960__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "comdef.h"
#pragma warning (disable : 4146)
#import "c:/program files/common files/system/ado/msado15.dll" no_namespace rename("EOF","ADOEOF")
#pragma warning (default:4146)

class ATTRIBUTE
{
public:
	_bstr_t strName;
	_bstr_t strValue;
};

class CXMLGenerator  
{
public:
	DWORD GetParameter();
	static BSTR CreateElement(BSTR strElementName,ATTRIBUTE * AttributeList, BOOL bHasValue, BSTR strElementValue);
	static BSTR XMLEncode(BSTR strEncode);
	virtual BSTR PostContent(_RecordsetPtr RS);
	virtual BSTR PreContent(_RecordsetPtr RS);
	virtual BSTR BeforeEnd();
	virtual BSTR AfterStart();
	virtual BOOL HasValue(BSTR strElementName, BSTR strFieldValue);
	virtual BSTR GetValue(BSTR strElementName, BSTR strFieldValue);
	virtual ATTRIBUTE * GetAttributeList(BSTR ElementName, _RecordsetPtr RS);
	virtual BSTR GetElementName(BSTR FieldName);
	virtual BSTR GenerateXML(_RecordsetPtr RS,BSTR strRootNode, BSTR strChildNode, DWORD lParam);
	CXMLGenerator();
	virtual ~CXMLGenerator();

private:
	BSTR GetNodeName(BSTR strNode);
	DWORD m_lParam;
protected:
	BSTR GetBSTR (VARIANT vtVar);
};

#endif // !defined(AFX_XMLGENERATOR_H__93788D78_DB54_4A37_B239_CBB0606D8960__INCLUDED_)
	

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