I coded and compiled my project on Ubuntu 9.10, g++ 4.4.1 with Netbeans 6.9.
The code is :
session sql;
string name = ""; //string name; or string name = "???"; give the
same result
int count = 0;
sql.open("mysql", "db=ranking_dev user=***** password=****");
sql << "select name from categories where id = 4", into(name);
I attached the .cpp file, but the rest is all copied from the online
example. I was suggested elsewhere to get a stack trace, which I'm still
trying to get, since gdb (or netbeans, I'm not sure) is currently playing
tricks and is not really working correctly. Thanks!
Simon
On Thu, Sep 30, 2010 at 5:12 PM, Julian Taylor <
[email protected]> wrote:
> On Thu, 2010-09-30 at 16:34 -0400, Simon Chenard wrote:
> > Hello,
> >
> >
> > First off, I never used a mailing list before... it's all pretty new
> > to me. Shouldn't pose any problem, but if I make a stupid mistake
> > please pardon me. So I started a new C++ project not too long ago, and
> > I decided to use SOCI to handle the database querying (MySQL). To test
> > my set-up I used the example
> > there : http://soci.sourceforge.net/doc/index.html which I modified a
> > little by eliminating the while clause and querying a db and table
> > which currently exist. I'm able to do a COUNT(*) and store it in a
> > int, but if I select (select name from categories where id = 4) a
> > varchar, and store it into a string, I get a Segmentation Fault. Which
> > is quite troublesome... I tried a few things (initializing the string,
> > messing with the query) but to no avails. I really don't have any
> > ideas on how to resolve this issue. Would anyone have one? Thanks!
> >
> >
> > Simon
>
> Hi,
> I cannot reproduce the problem.
> Can you provide code reproducing your problem.
>
> Best Regards,
> Julian Taylor
>
>
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> Soci-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/soci-users
>
>
//taken from SOCI online example
#include "/usr/local/include/soci/soci.h"
#include "/usr/local/include/soci/soci-mysql.h"
#include <iostream>
#include <istream>
#include <ostream>
#include <string>
#include <exception>
using namespace soci;
using namespace std;
int main()
{
try
{
session sql;
string name = "";
int count = 0;
sql.open("mysql", "db=ranking_dev user=root password=patate");
sql << "select name from categories where id = 4", into(name);
cout << "We have " << name << " entries in the categories.\n";
}
catch (exception const &e)
{
cerr << "Error: " << e.what() << '\n';
}
}------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users