|
Subject:
|
Posting checkboxlist parameters into database
|
|
Posted By:
|
rayncarnation
|
Post Date:
|
10/6/2005 9:59:19 AM
|
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
|
|