I'm a newbie with the POCO libraries. I need to read a DateTime field from an SQL Server (connected using ODBC Native Client). I have no problems reading strings or numbers, however Dates or Timestamps are giving me a difficult time... I'm not really sure if I should use a Poco::Timestamp to accomplish this. Apparently not.
#include <vector>
#include <iostream>
#define POCO_STATIC
#include <Poco/DateTime.h>
#include <Poco/DateTimeFormat.h>
#include <Poco/DateTimeFormatter.h>
#include <Poco/SharedPtr.h>
#include <Poco/Tuple.h>
#include <Poco/Data/SessionFactory.h>
#include <Poco/Data/Session.h>
#include <Poco/Data/ODBC/Connector.h>
using namespace Poco::Data;
int main() {
typedef Poco::Tuple<std::string, Poco::Timestamp> Event;
typedef std::vector<Event> Events;
Poco::Data::ODBC::Connector::registerConnector();
Session session("ODBC", "DSN=TestSNAC");
Events events;
Statement select(session);
select << "select Name, StartDate from Events order by Name", into(events), now;
for (Events::const_iterator it = events.begin(); it != events.end(); it++) {
std::string date(Poco::DateTimeFormatter::format(it->get<1>(), "%b %e, %Y"));
std::cout << " Name: " << it->get<0>()
<< " Start: " << date << std::endl;
}
return 0;
}
I'm getting the following error during compiling on line 27 (that is the one that starts with 'select << "select Name...):
error C2664: 'bool Poco::Data::AbstractExtractor::extract(size_t,Poco::Int8 &)' : cannot convert parameter 2 from 'Poco::Timestamp' to 'Poco::Int8 &'
Thank you so much...