27 #include "../common/Exception.h"
28 #include "../common/Translator.h"
36 #include <boost/format.hpp>
50 _bstr_t connStr = conninfo.c_str();
61 std::string err =
TE_TR(
"ADO Connection: ");
62 err += (LPCSTR)e.ErrorMessage();
66 long status =
m_conn->GetState();
68 if(status != adStateOpen)
70 boost::format errmsg(
TE_TR(
"It was not possible to create a connection to the given data source due to the following error: %1%."));
72 errmsg = errmsg %
m_conn->GetErrors()->GetItem(0)->GetDescription();
85 if (m_conn->GetState() == ::adStateOpen)
93 _RecordsetPtr recordset;
95 TESTHR(recordset.CreateInstance(__uuidof(Recordset)));
102 recordset->Open(query.c_str(), _variant_t((IDispatch *)m_conn), adOpenStatic, adLockReadOnly, adCmdText);
106 std::string err =
TE_TR(
"ADO Connection: ");
107 err += (LPCSTR)e.ErrorMessage();
118 m_conn->Execute(_bstr_t(command.c_str()),0, adCmdText);
122 std::string err =
TE_TR(
"ADO Connection: ");
123 err += (LPCSTR)e.ErrorMessage();
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.
A class that implements a connection to a ADO database.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
_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.