Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to store and retrive chekbox values in databse in c# winform...
i wana to store and retrive values of chekbox and chek list box ..plz guide me
Posted

Hi if your DBMS is SQL server, you must display boolean value with Bit Data Type.this Data Type take two value:
1- 0 means false
2- 1 mean true
when you bind your application to sql it automatically do all thing.
good luck
 
Share this answer
 
Hi
this will defiantly help you..

go throw this link..

http://stackoverflow.com/questions/14092494/retrieve-checkboxlist-value-in-c-net[^]

Happy to help
 
Share this answer
 
you can try this, hope it will meet your requirement
if(checkBox1.checked == true)
{
   string value = "your Value";
}
sqlcommand cmd = new sqlcommand("INSERT INTO yourtable (column-name) VALUE ('"+ value +"'), con);
cmd.executeNonQuery();

i showed u a code snippet using concatenation,but its better idea to pass parameter.
hope this will help you
if any question plz ask.
regards
bunzitop
 
Share this answer
 
Comments
Jegan Thiyagesan 10-Mar-13 10:50am    
when sql can perfectly handle Boolean type, why change to string. In programming if the developer can code something in primitive type, then it should be left alone in primitive type. Converting a primitive type to another type and back again into primitive type is totally unnecessary.
bunzitop 11-Mar-13 9:27am    
yes you are totally right! i agree with you
but i showed above example because if he wants to save string value from checkBox instead of boolean value,
My solution is not final solution, the solution is dependent on his requirement
thanks for comment :)
regards
bunzitop

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