27 #include "../common/Translator.h"
36 #include <boost/format.hpp>
50 _bstr_t connStr = conninfo.c_str();
59 throw Exception(
TE_TR(e.Description()));
62 long status =
m_conn->GetState();
64 if(status != adStateOpen)
66 boost::format errmsg(
TE_TR(
"It was not possible to create a connection to the given data source due to the following error: %1%."));
68 errmsg = errmsg %
m_conn->GetErrors()->GetItem(0)->GetDescription();
74 throw Exception(errmsg.str());
81 if (m_conn->GetState() == ::adStateOpen)
87 _RecordsetPtr recordset;
89 TESTHR(recordset.CreateInstance(__uuidof(Recordset)));
96 recordset->Open(query.c_str(), _variant_t((IDispatch *)m_conn), adOpenStatic, adLockReadOnly, adCmdText);
100 throw Exception(
TE_TR(e.Description()));
110 m_conn->Execute(_bstr_t(command.c_str()),0, adCmdText);
114 throw Exception(
TE_TR(e.Description()));
Connection(const std::string &conninfo)
Constructor.
_RecordsetPtr query(const std::string &query, bool connected=false)
It queries the database.
#define TE_TR(message)
It marks a string in order to get translated.
An exception class for ADO.
A class that implements a connection to a ADO database.
_ConnectionPtr m_conn
The ADO real connection handle.
void execute(const std::string &command)
It executes the given SQL command and throws away the result.
A class that implements a connection to a ADO database.