1,105,578 Community Members

how to save checkbox in sql DB using asp.net vb

Member Avatar
aalshamr
Newbie Poster
1 post since Sep 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hello to all

am new programmer facing a problem in saving three checkboxs into database

for example
a
b
c

all of the has a value in the database

any one can heple from scratch

I'll be greatfull

regards,

Member Avatar
Begginnerdev
Veteran Poster
1,142 posts since Apr 2010
Reputation Points: 251 [?]
Q&As Helped to Solve: 191 [?]
Skill Endorsements: 15 [?]
 
0
 

Such a broad question makes it very difficult to give a good answer.

When you are wanting to store the check boxes, are you checking for yes/no values or something like options a new vehicle?

If you are storing yes/no then it is as simple as storning them in bit/tinyint/boolean fields.

An example for SQL Server (using bit and the OleDB library) would be:

Dim iBitVal As Integer = IIf(CheckBox1.Checked,1,0)
Dim cmdUpdate As New OleDBCommand("UPDATE myTable Set bitColumn1=" & iBitVal & " WHERE UniqueField=MyUniqueValue",MyOleDBConnection)
cmd.Update()

If you are storing something such as options on a new vehicle, you will to design your table accordingly. You can store them all in one field using a max length column or you could create a field for each option (only if constant - Very sloppy but some times manditory)

I hope this helps.

Please provide more infromation for a better answer. :)

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: