OLEDB Accessor mapping of 'bit' datatype
-
Greetings, Before I start tearing my hair out I wondered if anyone might be able to help. Thus far I have no problem in using OLEDB with SQL Compact via an accessor BUT I simply cannot find out what native data type to map a 'bit' value to. At present I have the following which compiles fine.
class CDBMain
{
public:
// Data Elements
BOOL f_HubDel;
...
// Column binding map
BEGIN_COLUMN_MAP(CDBMain)
COLUMN_ENTRY(1, f_HubDel)
...However at runtime I have binding errors like this.
Binding entry 0 failed. Status: 2
Now I am about to rework the SQL DB schema to use a CHAR[1] but if anyone can tell me what I am doing wrong then you will save me a lot of work. Many thanks
Alan
-
Greetings, Before I start tearing my hair out I wondered if anyone might be able to help. Thus far I have no problem in using OLEDB with SQL Compact via an accessor BUT I simply cannot find out what native data type to map a 'bit' value to. At present I have the following which compiles fine.
class CDBMain
{
public:
// Data Elements
BOOL f_HubDel;
...
// Column binding map
BEGIN_COLUMN_MAP(CDBMain)
COLUMN_ENTRY(1, f_HubDel)
...However at runtime I have binding errors like this.
Binding entry 0 failed. Status: 2
Now I am about to rework the SQL DB schema to use a CHAR[1] but if anyone can tell me what I am doing wrong then you will save me a lot of work. Many thanks
Alan
Just a guess here but did you try with bool (lowercase bool, not BOOL)? Or maybe with a bitfield type, like:
int f_HubDel:1;
orunsigned int f_HubDel:1;
?> The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
-
Just a guess here but did you try with bool (lowercase bool, not BOOL)? Or maybe with a bitfield type, like:
int f_HubDel:1;
orunsigned int f_HubDel:1;
?> The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
Sorry but that does not work either. Since I posted I have been doing some digging and I found the following in atldbcli.h
DEFINE\_OLEDB\_TYPE\_FUNCTION(SHORT ,DBTYPE\_I2) // DBTYPE\_BOOL
So you would think SHORT would do... Nope that fails to bind too. I have found two solutions 1. Update atldbcli.h to include your own
DEFINE_OLEDB_TYPE_FUNCTION
forDBTYPE_BOOL
2. Use aCAST
in the SQL command to convert the value to anint
as follows.CAST(Table.BitField AS int) AS AltName
Personally I have decided to stick to the latter. I hope this will save someone the pain I have just been through. :sigh:
Alan