Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. OLEDB Accessor mapping of 'bit' datatype

OLEDB Accessor mapping of 'bit' datatype

Scheduled Pinned Locked Moved C / C++ / MFC
databasehelpc++wpfwcf
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Spawn Melmac
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • S Spawn Melmac

      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

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      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; or unsigned 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. <

      S 1 Reply Last reply
      0
      • C Code o mat

        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; or unsigned 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. <

        S Offline
        S Offline
        Spawn Melmac
        wrote on last edited by
        #3

        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 for DBTYPE_BOOL 2. Use a CAST in the SQL command to convert the value to an int 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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups