Check box and database

Results 1 to 2 of 2

Thread: Check box and database

  1. #1
    Join Date
    Dec 1969

    Default Check box and database

    Hello! Can anyone tell me how to save the value of multiple independent check boxes in database? And what is the datatype of the checkbox in database? Is it "Yes/No" datatype? Thank you!<BR>

  2. #2
    Join Date
    Dec 1969

    Default Basic ASP

    Checkboxes are yes/no, yes. But in the programming world that is known as booleon or true/false. This is really basic, you should look around at the various asp sites and look at their beginning articles, heres a quick and dirty example.<BR><BR>Page 1:<BR>&#060;form action="page2.asp"&#062;<BR>&#060;input type="checkbox" name="check1"&#062;<BR>&#060;input type="submit" value="submit"&#062;<BR>&#060;/form&#062;<BR><BR>Page 2:<BR>&#060;% &#039;pull value of checkbox out of querystring<BR>dim checkbox1<BR>checkbox1 = request("check1")<BR><BR>&#039;open database connection and recordset<BR>dim objConn, SQL<BR>set objConn = Server.CreateObject("ADODB.Connection")<BR>objConn .Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _<BR>"Data Source=e:inetpubwwwrootdatabase.mdb;" & _<BR>"Persist Security Info=False"<BR><BR>&#039;define your SQL<BR>SQL = "INSERT INTO table VALUES (checkbox1)<BR><BR>&#039;execute SQL<BR>objConn.execute(SQL)<BR><BR>&#039;close connection<BR>objConn.close<BR>set objConn = nothing<BR><BR>If you want to put more than one checkbox in, like you said, name them something else and put them in your database just like I did here. DO NOT try to use this code though, go read a dozen beginning ASP articles and learn about connections and recordsets and SQL and all that other fun stuff.<BR><BR>Thank you come again!

Posting Permissions

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