Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB8.0 SQL-Server
I am developing a visitor system..
visitor can visit to many place in one time..
so, I use check box to checked the place they want to go..
in my system there are 3 option of place..
they must checked at least 1 check box..
so, how to store this check box value?
please help me....
Posted 12-Mar-11 16:04pm
Edited 12-Mar-11 16:08pm
thatraja242.2K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Each checkbox is a simple True/False value. Unless you're using a TriState checkbox that is...
 
If you're using a normal checkbox, you check either use one database field for each checkbox, or you can assign bit flag values to each checkbox and "OR" those togther and save the resulting value.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Hi,
 
try this
 
set AutoPostBack="true" in Checkbox at design time and also set "OnCheckedChanged" event which will call the code behind function every time when user Select/Deselect CheckBox ...
 
SO when OnCheckedChanged Event is called in code behind you can write your code which will hit the database and before that check which checkbox is checked by CheckboxName.Checked = True and then call a function which will insert checked Checkbox value into database
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

No,i tried to refer the above mentioned link for the same query but these are not clear.Can anyone help with the code?
  Permalink  
Comments
walterhevedeich at 5-Apr-11 2:29am
   
Huh? are you the same person who posted the question? Anyway, no one will help you if all you want is the code. Its not the way it works here. You should have started with something and post questions here if you were stuck somewhere.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Can't say much.
 
Have a db named test, a table named activity with fields ActivityID and Activities
 
Got a form with one textbox named txtactivity. Visible property set to false.
 
got a label with text Activities.
Got Six checkboxes with six different options.
And of course a button
Code works but needs some extra touch. If you can make it shoter, tha'll be cool.
 
Imports System.Data.SqlClient
Public Class Form1
 
    'path variable use for Get application running path
    Dim path As String = (Microsoft.VisualBasic.Left(Application.StartupPath, Len(Application.StartupPath) - 9))
    Dim con As New SqlConnection("Data Source=localhost;Initial Catalog=test;Integrated Security=True")
    Dim cmd As SqlCommand
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      
 
        If CheckBox1.Checked = False And CheckBox2.Checked = False And CheckBox3.Checked = False And CheckBox4.Checked = False And CheckBox5.Checked = False And CheckBox6.Checked = False Then
            MsgBox("Please select atleast one activity")
 
        Else
            If CheckBox1.Checked Then
                CheckBox1.Text = CheckBox1.Text
 
            Else : CheckBox1.Text = ""
            End If
 
            If CheckBox2.Checked = True Then
                CheckBox2.Text = CheckBox2.Text
 
            Else : CheckBox2.Text = ""
            End If
 
            If CheckBox3.Checked = True Then
                CheckBox3.Text = CheckBox3.Text
 
            Else : CheckBox3.Text = ""
            End If
 
            If CheckBox4.Checked = True Then
                CheckBox4.Text = CheckBox4.Text
 
            Else : CheckBox4.Text = ""
            End If
 
            If CheckBox5.Checked = True Then
                CheckBox5.Text = CheckBox5.Text
 
            Else : CheckBox5.Text = ""
            End If
 
            If CheckBox6.Checked = True Then
                CheckBox6.Text = CheckBox6.Text
 
            Else : CheckBox6.Text = ""
            End If
            txtactivity.Text = CheckBox1.Text + " " + CheckBox2.Text + " " + CheckBox3.Text + " " + CheckBox4.Text + " " + CheckBox5.Text + " " + CheckBox6.Text
 

            Dim sql As String = "INSERT INTO Activity VALUES(@Activities)"
            Dim cmd As New SqlCommand(sql, con)
            cmd.Parameters.AddWithValue("@Activities", txtactivity.Text)
            cmd.ExecuteNonQuery()
            MessageBox.Show("Information has been saved", "Save", MessageBoxButtons.OK)
 
        End If
 
        
    End Sub
 
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        con.Open()
 
    End Sub
 
End Class
  Permalink  
v2
Comments
CHill60 at 13-Aug-13 8:48am
   
Apart from the fact the original question is over 2 years old ... what is the point of the lines like "CheckBox1.Text = CheckBox1.Text"???

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

  Print Answers RSS
0 OriginalGriff 341
1 Marcin Kozub 225
2 Sergey Alexandrovich Kryukov 220
3 Praneet Nadkar 197
4 Shweta N Mishra 161
0 OriginalGriff 8,149
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 13 Aug 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100