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??
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
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
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
root = tkinter.Tk()
buttons=[i for i in range(10)]
#If specific button is pressed, output "YES"
for num in buttons: