Mailing List
Home
Forum Home
MySQL General - General MySQL discussion
MySQL++ - Programming with the C++ API to MySQL
MaxDB - Everything about MaxDB, formerly known as SAP DB
ODBC - ODBC with the MySQL Connector/ODBC driver
MySQL on Win32 - Runing MySQL on Windows 9x/Me/NT/2000/XP
Java Help - Mostly related to the MySQL Connector/J driver
Perl - Perl support for MySQL with DBI and DBD::mysql
GUI - MySQL GUI Tools
Announcement
Subjects
Subject: mysql openssl Question
ERROR 1045: Access denied for user: 'root@localhost ' (Using
password: NO)
Update one field with more fields from another table
Subject: Getting Identity after INSERT
ERROR 2002: Can 't connect to local MySQL server through socket
mysql test 4 1 fails with the gis test
Subject: MySQL Cluster Software
Downgrade Mysql from 4 to 3 23
Mysql 4 0 Oracle Stored Procedure Trigger Conversion
Can 't access mysql after kernel upgrade
Executing MySQL Commands From Within C Program
Comparing and writing out BLOBS
Subject: Re: Preventing Duplicate Entries
FULLTEXT query format question
Strange behavior, Table Level Permission
Does the binary log enabling affect the MySQL performances?
mysql:it 's a db not a dbms how it 's possible?!
mysql have same function mthod as Oracle decode()
 
Subject: Re: Null values do not compile...

Subject: Re: Null values do not compile...

2007-10-03       - By Maarten Schrijvers

 Back
OK. I Google'd and saw many people had similar problems with ambiguity in
VS2005. However, I didn't find how they resolved their problems (if at all).
So I decided to create a work-around which I would like to share:
Passing a "(NULL)" string to my database where a trigger sets that value to
a proper SQL null.

Quite simple actually, just a pain in the butt to maintain it in two places,
but hey can't have it all ;)


2007/10/2, Maarten Schrijvers <maarten.schrijvers@(protected)>:
>
> I have some fields which can be (SQL) NULL. If they are filled they are
> varchar, but they're not necessary, so they could be NULL.
> Compiling gives me an error though:
>
> c:\mysql++\include\null.h(206) : error C2593: 'operator =' is ambiguous
>
> 1> E:\Program Files\Microsoft Visual Studio 8\VC\include\xstring(923):
> could be 'std::basic_string<_Elem,_Traits,_Ax>
> &std::basic_string<_Elem,_Traits,_Ax>::operator =(_Elem)'
>
> 1> with
>
> 1> [
>
> 1> _Elem=char,
>
> 1> _Traits=std::char_traits<char>,
>
> 1> _Ax=std::allocator<char>
>
> 1> ]
>
> 1> E:\Program Files\Microsoft Visual Studio 8\VC\include\xstring(918): or
> 'std::basic_string<_Elem,_Traits,_Ax>
> &std::basic_string<_Elem,_Traits,_Ax>::operator =(const _Elem *)'
>
> 1> with
>
> 1> [
>
> 1> _Elem=char,
>
> 1> _Traits=std::char_traits<char>,
>
> 1> _Ax=std::allocator<char>
>
> 1> ]
>
> 1> E:\Program Files\Microsoft Visual Studio 8\VC\include\xstring(913): or
> 'std::basic_string<_Elem,_Traits,_Ax>
> &std::basic_string<_Elem,_Traits,_Ax>::operator =(const
> std::basic_string<_Elem,_Traits,_Ax> &)'
>
> 1> with
>
> 1> [
>
> 1> _Elem=char,
>
> 1> _Traits=std::char_traits<char>,
>
> 1> _Ax=std::allocator<char>
>
> 1> ]
>
> 1> while trying to match the argument list '(mysqlpp::sql_varchar,
> mysqlpp::null_type)'
>
> 1> c:\mysql++\include\null.h(204) : while compiling class template member
> function 'mysqlpp::Null<Type>::operator Type(void)'
>
> 1> with
>
> 1> [
>
> 1> Type=mysqlpp::sql_varchar
>
> 1> ]
>
> 1> e:\visual studio
> 2005\projects\t_1\urenregistratie\Relatieonderhoud.h(25) : see reference to
> class template instantiation 'mysqlpp::Null<Type>' being compiled
>
> 1> with
>
> 1> [
>
> 1> Type=mysqlpp::sql_varchar
>
> 1> ]
>
> I have declared the following:
>
> typedef
> mysqlpp::Null<mysqlpp::sql_varchar> Nullstr;
>
> static
> Nullstr vVoornamen = mysqlpp::null; //gave the variable a value trying to
> avoid the error
>
> What am I doing wrong?
>