hi dears..
i have really big problem with save values of checkedlistbox in one field but i can't do it..what can i do??
is it a database or code problem??
i want the data save like this: 1;2;3 for example..is that possible??

plzzz help..


I can't tell until I see your code...

Is it you want to store which checkboxes the person has checked them?

hi..thanks for reply..yes i want to store the checked box by user which may be more than one value but i need them in one field as i explained previously..

here is sample from code:

 Private Sub confirm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles confirm.Click
        Dim cmd As New OleDbCommand
        Dim y As New OleDbParameter("Num", OleDbType.Integer)
        Dim x As New OleDbParameter("Q3_2c", OleDbType.Integer)
        Dim i, j As New Integer

            J = 0

            For i = 0 To CheckedListBox1.Items.Count - 1

                If CheckedListBox1.CheckedItems(i) = True Then

                    J = J + 1

                End If

                For Each check In CheckedListBox1.CheckedItems(i)

                    cmd.CommandText = "INSERT INTO Test([Num],[Q3_2c])VALUES(" + No.Text + "," + check + ")"
                    cmd.CommandType = CommandType.TableDirect
                    cmd.Connection = conn
        Catch ex As Exception
        End Try
        End Sub

Try to transfer your checkedlistbox item to Textbox, then you may insert it to Access or others. Hope you got the Idea.

thanks for reply..but i can't do this because i have more than 50 values for this list and user isn't able to check with out choose a case whiyh i already determine befor this step..hope you got ma idea..


There are are a couple of ways you can do this, seeing as you only have one field to store it in and you could loop through your items as you are doing and if the item.checked then append it to a string that you then store in the DB field. This is nasty though when it comes to reading back.. as you will have to parse through a long list of delimited text to see what the user clicked.

If you understand bitwise logic you could store the whole thing as a single numeric field and use comparisons to see which checkboxes were checked. I've done this before for storing a users options on a web site but it was ages ago and I can't quite remember how I did it.

I think I assigned a numeric ID to each option then when the user selected it I used an OR to store it in my database field i.e. NewUserValue = OldUserValue OR SelectedOptionID

Then when it came to to see if the user had checked the option, I used an AND like so
IF UsersSelectedOption AND UsersOption = UsersOption then - option is selected


I think your values would have to be in the order 1,2,4,8,16,32,64,128,256 etc

i.e. if I used a value 3 then SelectedOptions AND 2 = 2 would be true as 3 = 11 and 2 = 10

thanks dear 4 reply..but i didn't get it..am sorry..am really new in this..could you please show me how can i fix my code to perform your idea??