Check box

J

JJ297

Hello can someone assist me...


I've added two check boxes to my page


<asp:CheckBox ID="ChkYes" runat="server" Text="Yes" /><br />
<asp:CheckBox ID="ChkNo" runat="server" Text="No" /

I have a stored procedure set up to enter in the Yes or No answer.
How do I set that up on the code behind page?

This is what I have thus far, all of the other data on the page is
going into the database now I just need to add the check box value.

The two fields in the Database are called DisplayedQues and
NonDisplayedQues

Dim question As String = TxtQuestion.Text
Dim answer As String = TxtAnswer.Text


Dim conn As New Data.SqlClient.SqlConnection("Data
Source=seb2a54;Initial Catalog=EDCSFAQS;Persist Security
Info=True;User ID=EDCSFAQUser;Password=fax")

Dim cmd As New Data.SqlClient.SqlCommand
With cmd
..Connection = conn 'the connection
..CommandType = Data.CommandType.StoredProcedure
..CommandText = "EnterAdminQuestion"
..Parameters.AddWithValue("@topicid",
CInt(DropDownList1.SelectedItem.Value))
..Parameters.AddWithValue("@quesdate", QuesDate.Text)
..Parameters.AddWithValue("@questions", TxtQuestion.Text)
..Parameters.AddWithValue("@Answer", TxtAnswer.Text)
..Parameters.AddWithValue("@DisplayedQues", what do I put here???)
..Parameters.AddWithValue("@NonDisplayedQues", what do I put here???)

Thanks so much.
 
C

Cowboy \(Gregory A. Beamer\)

Dim displayedQues as Boolean = False
Dim nonDisplayedQues as Boolean = False

If (ChkYes.Checked) Then
displayedQues = True
End If

If (ChkNo.Checked) Then
nonDisplayedQues = True
End If


Dim cmd As New Data.SqlClient.SqlCommand
With cmd
..Connection = conn 'the connection
..CommandType = Data.CommandType.StoredProcedure
..CommandText = "EnterAdminQuestion"
..Parameters.AddWithValue("@topicid",
CInt(DropDownList1.SelectedItem.Value))
..Parameters.AddWithValue("@quesdate", QuesDate.Text)
..Parameters.AddWithValue("@questions", TxtQuestion.Text)
..Parameters.AddWithValue("@Answer", TxtAnswer.Text)
..Parameters.AddWithValue("@DisplayedQues", displayedQues)
..Parameters.AddWithValue("@NonDisplayedQues", nonDisplayedQues)
 
J

JJ297

Dim displayedQues as Boolean = False
Dim nonDisplayedQues as Boolean = False

If (ChkYes.Checked) Then
displayedQues = True
End If

If (ChkNo.Checked) Then
nonDisplayedQues = True
End If

Dim cmd As New Data.SqlClient.SqlCommand
With cmd
.Connection = conn 'the connection
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "EnterAdminQuestion"
.Parameters.AddWithValue("@topicid",
CInt(DropDownList1.SelectedItem.Value))
.Parameters.AddWithValue("@quesdate", QuesDate.Text)
.Parameters.AddWithValue("@questions", TxtQuestion.Text)
.Parameters.AddWithValue("@Answer", TxtAnswer.Text)
.Parameters.AddWithValue("@DisplayedQues", displayedQues)
.Parameters.AddWithValue("@NonDisplayedQues", nonDisplayedQues)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBAhttp://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!














- Show quoted text -


Thanks for assisting me I'm all set but have another question...

I have a field in this same database called CDPPin. I'm using a
session variable to get the pin. How do I call it? Do I...

Dim Session (CDPUser)

Then call it like this?
.Parameters.AddWithValue("@DisplayedQues", displayedQues)
.Parameters.AddWithValue("@NonDisplayedQues", nonDisplayedQues)
.. Parameters.AddWithValue("@CDPPin", CDPPin)?
 
L

Lit

Dim CDPPin as Integer
CDPPin = CType(Session("CDPUser"), Integer)

pass CDPPin to Stored procedure.
 
C

Cowboy \(Gregory A. Beamer\)

Assuming it is an Integer. If not, you will have to change to the correct
type, but Lit is right on track with the solution.
 
J

JJ297

Assuming it is an Integer. If not, you will have to change to the correct
type, but Lit is right on track with the solution.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBAhttp://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside thebox!







- Show quoted text -

Thanks so much with you assistance. Just getting back from vacation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top