Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 6th, 2005, 09:59 AM
Authorized User
 
Join Date: Aug 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default Posting checkboxlist parameters into database

Hello,

I would like to make a form with a checkbox list. The information is then passed to a Access database. I've structured the code as follows:

<asp:checkboxlist id="cblPurchaseFactors" runat="server">


<asp:listitem Value="cblFriendAdvice">Advice from a friend</asp:listitem>

<asp:listitem Value="cblDoctorAdvice"> Advice from a physician</asp:listitem>


</asp:checkboxlist>


Here is the code that would go into the event handler:

Select Case (cblPurchaseFactors.SelectedItem.Value)

Case “cblFriendAdvice”
Dim FriendAdviceParam as New OleDbParameter ("@cblFriendAdvice", OleDbType.VarChar)
 FriendAdviceParam.Value = cblFriendAdvice.Text
 dbCommand.Parameters.Add(FriendAdviceParam)

Case “cblDoctorAdvice”
Dim DoctorAdviceParam as New OleDbParameter ("@cblDoctorAdvice", OleDbType.VarChar)
 DoctorAdviceParam.Value = cblDoctorAdvice.Text
 dbCommand.Parameters.Add(DoctorAdviceParam)


Case else
Message.text = “You did not select where you got your advice”

End select


I am guessing at the code. Does that code make sense? I cannot test it out where I am. If not could someone please put me on the right track.

As well, I am confused as to how I would set up the Datafields in the Access Database. Would I make a field for every listitem such as:

cblFriendadvice

cblDoctorAdvice

or would I make identical fields to catch every item that a user checks such as:

PurchaseFactors

PurchaseFactors



thanks,

Ray








Similar Threads
Thread Thread Starter Forum Replies Last Post
Posting from a form to a access database rayncarnation ASP.NET 1.0 and 1.1 Basics 0 September 2nd, 2005 10:18 AM
CheckBoxList eddiema VS.NET 2002/2003 1 April 9th, 2004 09:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.