Click here to Skip to main content
15,893,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
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?

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.
 
Share this answer
 
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
ALTER TABLE mytable ADD mynewcolumn YESNO
 
Share this answer
 
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.
José Amílcar Casimiro 11-Feb-13 10:22am    
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
José Amílcar Casimiro 11-Feb-13 10:35am    
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 :)

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900