Click here to Skip to main content
12,453,873 members (78,085 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C++ SQL MFC
Hey guys


Do you have any ideas for creating a column (data type = bool -> show as check box) in Access by using SQl? I'm wrinting a tool in MFC, C++ and I need to safe some values in a database.

I allready tried this, which I found somewhere in the internet:
ALTER TABLE table_name ADD COLUMN column_name BIT

That doesn't work...


..I hope someone can help me.



Greetings
Epanjohura
Posted 11-Feb-13 4:08am
Comments
Maciej Los 11-Feb-13 10:20am
   
What you mean: "That doesn't work"?
epanjohura 11-Feb-13 10:32am
   
that means: I only get a created field (type = text) with the content 0 or 1, but I want to have "real" check boxes, where I can *check* values.
you know what I mean?
Maciej Los 12-Feb-13 8:30am
   
Now i understand.
epanjohura 12-Feb-13 8:26am
   
is there anybody who can help to solve this problem?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

ALTER TABLE mytable ADD mynewcolumn YESNO
  Permalink  
Comments
epanjohura 11-Feb-13 10:15am
   
thank you for your answer, but that doesn't work. it creates the same as the code I tried.
   
According to http://www.w3schools.com/sql/sql_datatypes.asp, YESNO is the default datatype for your question.
Maybe your problem have to do with your sql command, because True is equal to -1 and False is equal to 0.
Can you send more details about the problem or try to explain in a different way ?
epanjohura 11-Feb-13 10:30am
   
well, actually I want to have real check boxes in my access database, you know what I mean? with this YESNO commant I get only 0/1 as text in the created field
   
When you open your mdb file using the access, you want to see a check box instead of a 0/1 values?
epanjohura 11-Feb-13 10:36am
   
yes, exactly :)
   
Please check if this is applied to your question: http://office.microsoft.com/en-ca/access-help/create-a-check-box-toggle-button-or-option-button-HP005188421.aspx
epanjohura 11-Feb-13 11:14am
   
That's not what I'm looking for. This link shows an instruction how to do it manually after opening the database in Access in another view.
I want to do it automatically by just executing a command.
   
I can't help you. Additionally i don't event think that is possible.
epanjohura 11-Feb-13 11:28am
   
well, thank you anyway
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Storing data is not the same as presenting data. So, your field is still "bit" type and can store values: true/false, enabled/disabled, Yes/No.

I know, there are some differences between programming windows forms and MFC programming[^], but it changes nothing in our discuss. Remember, only application's user interface (UI) is responsible for data presentation layer and control. Embeded mechanisms route user input commands (checked selections, button clicks) to internal functions that may update the application's data. UI controls (windows, edit boxes, checkboxes, etc.) are responsible for displaying the application's data after each update.
  Permalink  
Comments
epanjohura 12-Feb-13 10:47am
   
that's not what I'm searching for..
Maciej Los 12-Feb-13 10:49am
   
Sorry...
epanjohura 12-Feb-13 10:50am
   
but thank you for trying

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 12 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100