[odb-users] Problem compiling for MS-SQL
boris at codesynthesis.com
Wed Jul 25 10:02:28 EDT 2012
Oded Arbel <oded at geek.co.il> writes:
> #pragma db type("NVARCHAR(9)")
> std::string ppd;
There is no default mapping between std::string and SQL Server national
character types (NVARCHAR, NCHAR, and NTEXT) since those are UTF-16
types. There is, however, a mapping for std::wstring so this will work:
#pragma db type("NVARCHAR(9)")
On the other hand, if you want to continue using std::string, then you
have to change the database type to VARCHAR(9) (or provide custom
mapping between NVARCHAR and std::string; see the 'mapping' example
For more information about available mappings in SQL Server, see
Section 17.1, "SQL Server Type Mapping" in the ODB Manual:
> I originally thought that the problem is that I'm using the binary
> windows compiler version 2.0.0 (the latest available on the site)
> while libodb is 2.0.1 (latest available), but I tried to "hello"
> example for MS-SQL (into which I added a simple class that is build
> similar to the above - with all the private/protected/public stuff)
> and it builds just fine.
Hm, that's strange. Did you also include the type("NVARCHAR(9)") part?
More information about the odb-users