Go to the documentation of this file.00001 #pragma once
00002
00003 namespace AppSecInc
00004 {
00005 namespace Databases
00006 {
00007 namespace ODBC
00008 {
00009 enum ODBCConnectionProtocol
00010 {
00011 ODBC_CONNECTION_UNSPECIFIED = -1,
00012 ODBC_CONNECTION_TCPIP = 0,
00013 ODBC_CONNECTION_NAMEDPIPES = 1,
00014 ODBC_CONNECTION_RPC,
00015 ODBC_CONNECTION_LPC,
00016 ODBC_CONNECTION_SPX,
00017 ODBC_CONNECTION_VINES,
00018 ODBC_CONNECTION_ADSP
00019 };
00020
00021
00023 const WORD ODBC_SQL_FLAG_NO_ROWS_RETURN_EMPTY = 0x0001;
00024
00025
00027 class ODBCConnection
00028 {
00029 protected:
00031 SQLHDBC _hconnection;
00033 SQLHENV _henvironment;
00035 BOOL _connected;
00036 public:
00037 ODBCConnection();
00038 virtual ~ODBCConnection();
00040 void Initialize();
00042 void Terminate();
00044 void Connect(const ODBCConnectionInfo& connection_info);
00046 void Disconnect();
00048 std::wstring GetError() const { return ODBCHandle::GetError(_hconnection, SQL_HANDLE_DBC); }
00050 std::vector<ODBCError> GetErrors() const { return ODBCHandle::GetErrors(_hconnection, SQL_HANDLE_DBC); }
00052 operator SQLHDBC() const { return _hconnection; }
00054 BOOL IsConnected() const { return _connected; }
00056 SQLHENV GetEnvironmentHandle() const { return _henvironment; }
00058 long GetScalar(const std::wstring& query) const;
00059 long GetScalar(const std::wstring& query, ODBCHandle& stmt) const;
00061 std::wstring GetXml(const std::wstring& query) const;
00063 MSXML2::IXMLDOMNodePtr GetXml(const std::wstring& query, AppSecInc::Xml::XmlDocument& xmldoc, MSXML2::IXMLDOMNodePtr parent_node = NULL) const;
00065 void InsertXml(const AppSecInc::Xml::XmlDocument& xmldatadoc);
00067 void InsertXml(const AppSecInc::Xml::XmlDocument& xmldatadoc, AppSecInc::Xml::XmlDocument& xmldoc, MSXML2::IXMLDOMNodePtr parent_node);
00069 void InsertXml(const AppSecInc::Xml::XmlDocument& xmldatadoc, MSXML2::IXMLDOMNodePtr result_node, AppSecInc::Xml::XmlDocument& xmldoc, MSXML2::IXMLDOMNodePtr parent_node);
00071 std::string GetString(const std::wstring& query, WORD flags = 0) const;
00073 std::string GetString(const std::wstring& query, ODBCHandle& stmt, WORD flags = 0) const;
00075 std::wstring GetWString(const std::wstring& query, WORD flags = 0) const;
00077 std::wstring GetWString(const std::wstring& query, ODBCHandle& stmt, WORD flags = 0) const;
00079 void Execute(const std::wstring& query) const;
00080 void Execute(const std::wstring& query, ODBCHandle&) const;
00082 void Execute(const std::wstring& query, ODBCRowSet&) const;
00084 void Execute(const std::wstring& query, ODBCParameters&) const;
00086 void Execute(const std::wstring& query, ODBCParameters&, ODBCRowSet&) const;
00087 };
00088 }
00089 }
00090 }
00091
00092
00093
00094
00095
00096
00097
00098