Storing Checkbox Values To a db

Results 1 to 2 of 2

Thread: Storing Checkbox Values To a db

  1. #1
    Join Date
    Dec 1969

    Default Storing Checkbox Values To a db

    My database has two fields, type1 and type2, each can contain one of four values derived from four checkboxes. The user can select two of the four checkbox items, i.e. (1&2 then not 3&4), etc. That part is working. The challegne now is writing the result to the database. I am using a parameterized query. &#062;&#062;INSERT PM (type1, type2) values (@type1, @type2).<BR><BR>This is the code for the checkbox selection:<BR>Sun Page_Load<BR>If chkCustomer.Checked And chkEmployee.Checked Then<BR> chkQuality.Enabled = False<BR> chkFinancial.Enabled = False<BR> ElseIf chkQuality.Checked And chkCustomer.Checked Then<BR> chkFinancial.Enabled = False<BR> chkEmployee.Enabled = False<BR>End If **It continues for each combination of two of the four checkbox items.<BR><BR>End Sub<BR><BR>Sub btnA_Click()<BR>**--&#062;How do I write the values to the db when I can only use the following statement once in my code without it blowing up?<BR>This blows up.<BR>cmdInsert.Parameters.Add("@TypeCode1", "C")<BR>cmdInsert.Parameters.Add("@TypeCode1", "E")<BR>cmdInsert.Parameters.Add("@TypeCode2", "C")<BR>cmdInsert.Parameters.Add("@TypeCode2", "E<BR>End Sub<BR>I need a way to enter into the database any combination of codes the correspond to the selected checkbox item.<BR><BR>Thank you.<BR><BR><BR><BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Storing Checkbox Values To a db

    Sub btnA_Click()<BR><BR>If chkCustomer.Checked And chkEmployee.Checked Then<BR> cmdInsert.Parameters.Add("@TypeCode1", "A")<BR> cmdInsert.Parameters.Add("@TypeCode1", "B")<BR>ElseIf chkQuality.Checked And chkCustomer.Checked Then<BR> cmdInsert.Parameters.Add("@TypeCode1", "C")<BR> cmdInsert.Parameters.Add("@TypeCode1", "D")<BR><BR>etc.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts