Is there any solution to this? I'm getting a similar problem:
Tried to convert "NULL" to a "j
I attached the complete gdb output. I'm writing my program with gtkmm.
Op wo, 25-01-2006 te 09:51 -0800, schreef Ece Karli:
> I have already read that section but could not get Null template compile if the type
> in the sql_create macro is one of those. I have copied my modified version of custom1.cpp
> file below. I am getting this compile error:
>
> d:\mysql++\include\coldata.h(300) : error C2666:
> 'mysqlpp::const_string::operator`[]'' : 2 overloads have similar conversions
> d:\mysql++\include\const_string.h(137): could be
> 'mysqlpp::const_string::const_reference mysqlpp::const_string::operator
> [](mysqlpp::const_string::size_type) const'
> or 'built-in C++ operator[(mysqlpp::cchar, int)'
> while trying to match the argument list '(const mysqlpp::ColData_Tmpl<Str>,
> int)'
> with
> [
> Str=mysqlpp::const_string
> ]
> d:\Test\TestMySQL\TestMySQL.cpp(57) : see reference to function template
> instantiation
> 'mysqlpp::ColData_Tmpl<Str>::operator`mysqlpp::Null<Type,Behavior>'(void)
> const' being compiled
> with
> [
> Str=mysqlpp::const_string,
> Type=double,
> Behavior=mysqlpp::NullisZero
> ]
>
>
> How am I supposed to use the template in that macro? Here is the code, I am trying to
> define weight as nullable field:
>
> typedef mysqlpp::Null<double, mysqlpp::NullisZero> MyNull;
>
> sql_create_5(stock,
> 1, 5, // explained in the user manual
> string, item,
> mysqlpp::longlong, num,
> MyNull, weight,
> double, price,
> mysqlpp::Date, sdate)
>
> int
> main(int argc, char *argv[])
> {
> // Wrap all MySQL++ interactions in one big try block, so any
> // errors are handled gracefully.
> try {
> // Establish the connection to the database server.
> mysqlpp::Connection con(mysqlpp::use_exceptions);
> if (!connect_to_db(argc, argv, con)) {
> return 1;
> }
> // Retrieve the entire contents of the stock table, and store
> // the data in a vector of 'stock' SSQLS structures.
> mysqlpp::Query query = con.query();
> query << "select * from stock";
> vector<stock> res;
> query.storein(res);
> // Display the result set
> print_stock_header(res.size());
> vector<stock>::iterator it;
> for (it = res.begin(); it != res.end(); ++it) {
> print_stock_row(it->item, it->num, it->weight, it->price,
> it->sdate);
> }
> }
> catch (const mysqlpp::BadQuery& er) {
> // Handle any query errors
> cerr << "Query error: " << er.what() << endl;
> return -1;
> }
> catch (const mysqlpp::BadConversion& er) {
> // Handle bad conversions; e.g. type mismatch populating 'stock'
> cerr << "Conversion error: " << er.what() << endl <<
> "\tretrieved data size: " << er.retrieved <<
> ", actual size: " << er.actual_size << endl;
> return -1;
> }
> catch (const mysqlpp::Exception& er) {
> // Catch-all for any other MySQL++ exceptions
> cerr << "Error: " << er.what() << endl;
> return -1;
> }
> return 0;
> }
>
>
> Warren Young <mysqlpp@stripped> wrote:
> Ece Karli wrote:
> >
> > I am getting conversion error when I try to read data into SSQLS
> > structure and value of an integer field is null.
>
>
> Read the user manual. There is a whole section on nulls (3.8), and why
> you have to treat them specially.
>
>
> --
> MySQL++ Mailing List
> For list archives: http://lists.mysql.com/plusplus
> To unsubscribe: http://lists.mysql.com/plusplus?unsub=1
>
>
>
>
>
>
> ---------------------------------
> Do you Yahoo!?
> With a free 1 GB, there's more in store with Yahoo! Mail.
--
If Linux doesn't have the solution, you have the wrong problem
(gdb) run
Starting program: /home/mario/progsels/gtkmm/fotoarch/progsel
glibmm-ERROR **:
unhandled exception (type std::exception) in signal handler:
what: Tried to convert "NULL" to a "j
aborting...
Program received signal SIGABRT, Aborted.
0xffffe410 in __kernel_vsyscall ()
(gdb) where
#0 0xffffe410 in __kernel_vsyscall ()
#1 0xb748e161 in raise () from /lib/libc.so.6
#2 0xb748fbbd in abort () from /lib/libc.so.6
#3 0xb780e520 in g_logv () from /usr/lib/libglib-2.0.so.0
#4 0xb780e5a7 in g_log () from /usr/lib/libglib-2.0.so.0
#5 0xb79c148e in Glib::exception_handlers_invoke () from /usr/lib/libglibmm-2.4.so.1
#6 0xb79c7d9e in Glib::SignalProxyNormal::slot0_void_callback () from
/usr/lib/libglibmm-2.4.so.1
#7 0xb7877417 in g_cclosure_marshal_VOID__VOID () from /usr/lib/libgobject-2.0.so.0
#8 0xb7869a7c in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#9 0xb7877097 in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0
#10 0xb787648c in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#11 0xb7876694 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#12 0xb7a5758c in gtk_button_clicked () from /usr/lib/libgtk-x11-2.0.so.0
#13 0xb7a58869 in gtk_button_get_alignment () from /usr/lib/libgtk-x11-2.0.so.0
#14 0xb7e2717e in Gtk::Button_Class::released_callback () from /usr/lib/libgtkmm-2.4.so.1
#15 0xb7877417 in g_cclosure_marshal_VOID__VOID () from /usr/lib/libgobject-2.0.so.0
#16 0xb7869c6d in g_cclosure_new_swap () from /usr/lib/libgobject-2.0.so.0
#17 0xb7869a7c in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#18 0xb7876b4d in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0
#19 0xb787648c in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#20 0xb7876694 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#21 0xb7a57525 in gtk_button_released () from /usr/lib/libgtk-x11-2.0.so.0
#22 0xb7a580f7 in gtk_button_set_relief () from /usr/lib/libgtk-x11-2.0.so.0
#23 0xb7edd707 in Gtk::Widget_Class::button_release_event_callback () from
/usr/lib/libgtkmm-2.4.so.1
#24 0xb7aeb77c in gtk_marshal_VOID__UINT_STRING () from /usr/lib/libgtk-x11-2.0.so.0
#25 0xb7869c6d in g_cclosure_new_swap () from /usr/lib/libgobject-2.0.so.0
#26 0xb7869a7c in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#27 0xb7876f56 in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0
#28 0xb78764ec in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#29 0xb7876694 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#30 0xb7b9c19e in gtk_widget_activate () from /usr/lib/libgtk-x11-2.0.so.0
#31 0xb7aea4ab in gtk_propagate_event () from /usr/lib/libgtk-x11-2.0.so.0
#32 0xb7aea827 in gtk_main_do_event () from /usr/lib/libgtk-x11-2.0.so.0
#33 0xb7957ca6 in gdk_event_get_graphics_expose () from /usr/lib/libgdk-x11-2.0.so.0
#34 0xb7807cc6 in g_main_depth () from /usr/lib/libglib-2.0.so.0
#35 0xb780892a in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#36 0xb7808c10 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#37 0xb780909f in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
#38 0xb7ae9d36 in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
#39 0xb7e6fbd7 in Gtk::Main::run_impl () from /usr/lib/libgtkmm-2.4.so.1
#40 0xb7e6fde9 in Gtk::Main::run () from /usr/lib/libgtkmm-2.4.so.1
#41 0x080569c0 in main ()
(gdb) quit