473,320 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Another Check box question...

Can't get null into the database. I'm trying to achieve...

if displayedQues = "Y" then I want nondisplayedques to go into the
database as null. What do I need to do? This is what I have thus
far.
Dim displayedQues As Char = "Y"
Dim nonDisplayedQues As Char = "N"
If (RadioYes.Checked) Then
displayedQues = "Y"
End If

If (RadioNo.Checked) Then
nonDisplayedQues = "N"
End If
Thanks for your assistance.

Aug 14 '07 #1
7 1529
"JJ297" <nc***@yahoo.comwrote in message
news:11**********************@l70g2000hse.googlegr oups.com...
What do I need to do?
Difficult to say with what you've provided so far...

Are you building up dynamic SQL (hopefuly not!), or are you using a
paremeterised query...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 14 '07 #2
On Aug 14, 8:09 am, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"JJ297" <nc...@yahoo.comwrote in message

news:11**********************@l70g2000hse.googlegr oups.com...
What do I need to do?

Difficult to say with what you've provided so far...

Are you building up dynamic SQL (hopefuly not!), or are you using a
paremeterised query...?

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
Not sure what you mean. I have two check boxes on the design page
that ask user to select yes or no if they want their question
displayed on the FAQ sheet.

On button click I have the above code. I wanted if the answer is yes
then put a Y in the database for Yes and Null for N.

Aug 14 '07 #3
JJ297 wrote:
On Aug 14, 8:09 am, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
>"JJ297" <nc...@yahoo.comwrote in message

news:11**********************@l70g2000hse.googleg roups.com...
>>What do I need to do?
Difficult to say with what you've provided so far...

Are you building up dynamic SQL (hopefuly not!), or are you using a
paremeterised query...?

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net

Not sure what you mean. I have two check boxes on the design page
that ask user to select yes or no if they want their question
displayed on the FAQ sheet.

On button click I have the above code. I wanted if the answer is yes
then put a Y in the database for Yes and Null for N.
If [CheckBox].Checked = True Then
' Do something
Else
' Do something Else
End if
Aug 14 '07 #4
JJ297 wrote:
On Aug 14, 8:09 am, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
>"JJ297" <nc...@yahoo.comwrote in message

news:11**********************@l70g2000hse.googleg roups.com...
>>What do I need to do?
Difficult to say with what you've provided so far...

Are you building up dynamic SQL (hopefuly not!), or are you using a
paremeterised query...?

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net

Not sure what you mean. I have two check boxes on the design page
that ask user to select yes or no if they want their question
displayed on the FAQ sheet.

On button click I have the above code. I wanted if the answer is yes
then put a Y in the database for Yes and Null for N.
Ignore my previous post. I misread your question.

You need to provide us with some of your database logic, at the moment
your telling us nothing about how you are achiving the database insert,
or any structure of the table concerned.
Aug 14 '07 #5
On Aug 14, 8:21 am, Mick Walker <materiali...@privacy.netwrote:
JJ297 wrote:
On Aug 14, 8:09 am, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"JJ297" <nc...@yahoo.comwrote in message
>news:11**********************@l70g2000hse.googleg roups.com...
>What do I need to do?
Difficult to say with what you've provided so far...
Are you building up dynamic SQL (hopefuly not!), or are you using a
paremeterised query...?
--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
Not sure what you mean. I have two check boxes on the design page
that ask user to select yes or no if they want their question
displayed on the FAQ sheet.
On button click I have the above code. I wanted if the answer is yes
then put a Y in the database for Yes and Null for N.

Ignore my previous post. I misread your question.

You need to provide us with some of your database logic, at the moment
your telling us nothing about how you are achiving the database insert,
or any structure of the table concerned.- Hide quoted text -

- Show quoted text -
Sorry about that... here's the code behind page:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim question As String = TxtQuestion.Text
Dim answer As String = TxtAnswer.Text

Dim CDPPin As String = Session("GetPin")

Dim displayedQues As Char = "Y"
Dim nonDisplayedQues As Char = "N"
Dim conn As New Data.SqlClient.SqlConnection("Data
Source=seb2a54;Initial Catalog=EDCSFAQS;Persist Security
Info=True;User ID=EDCSFAQUser;Password=fax") 'this is the conn from
frontpage

If (RadioYes).Checked = True Then
displayedQues = "Y"
Else : displayedQues = ""

End If

If (RadioNo).Checked = True Then
nonDisplayedQues = "N"
Else : nonDisplayedQues = ""
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)
.Parameters.AddWithValue("@CDPPin", CDPPin)
End With

Try
conn.Open()
cmd.ExecuteNonQuery()

Catch ex As Data.SqlClient.SqlException
Throw New ApplicationException("An error occurred while
trying to insert the record")
Finally
conn.Close()
End Try

Lbloutcome.Text = "Your entry was submitted into the
database."
End Sub

Aug 14 '07 #6
"JJ297" <nc***@yahoo.comwrote in message
news:11********************@g4g2000hsf.googlegroup s.com...
.Parameters.AddWithValue("@DisplayedQues", displayedQues)
If (RadioYes).Checked = True Then
.Parameters.AddWithValue("@DisplayedQues", displayedQues)
Else
.Parameters.AddWithValue("@DisplayedQues", System.DbNull.Value)
End If
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 14 '07 #7
On Aug 14, 9:02 am, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"JJ297" <nc...@yahoo.comwrote in message

news:11********************@g4g2000hsf.googlegroup s.com...
.Parameters.AddWithValue("@DisplayedQues", displayedQues)

If (RadioYes).Checked = True Then
.Parameters.AddWithValue("@DisplayedQues", displayedQues)
Else
.Parameters.AddWithValue("@DisplayedQues", System.DbNull.Value)
End If

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
THANKS!

Aug 14 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: claudel | last post by:
Hi I have a newb PHP/Javascript question regarding checkbox processing I'm not sure which area it falls into so I crossposted to comp.lang.php and comp.lang.javascript. I'm trying to...
2
by: Renie83 | last post by:
Hi I really am going crazy! I'm using VBScript, ASP, and SQL My page reminds me of a shopping cart but looking at shopping cart examples has not helped! What I have is a page that brings in...
51
by: nospam | last post by:
THIS IS the DOTNETJUNKIES MESSAGE ------------------------- We're Sorry As many of you know we have recently launched SqlJunkies.com. We have overhauled our runtime and will be using it on...
2
by: Daniel | last post by:
I use an Access database to basically take data exports, import them, manipulate the data, and then turn them into exportable reports. I do this using numerous macros, and queries to get the data...
2
by: Brian Basquille | last post by:
Another question for ye all.. How do i check if a Region has entered another region? Up until now, i've been checking if rectangles (or images converted into Rectangles) have been visible in a...
18
by: J-T | last post by:
Hi All, There is a picture on the following URL which I want to have it in one of my asp.net pages .I mean I want to embed the content of this page in my own page and get its image.Is there a...
17
by: Eric_Dexter | last post by:
def simplecsdtoorc(filename): file = open(filename,"r") alllines = file.read_until("</CsInstruments>") pattern1 = re.compile("</") orcfilename = filename + "orc" for line in alllines: if not...
5
by: Rex | last post by:
Hi, I want to change a value in one table depending on the value(s) in another table. I am trying to achieve this in a form. to elaborate I have a many-to-many relationship between tables...
6
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I check to see if a childwindow is open, before opening another?...
3
by: leonardodiserpierodavinci | last post by:
Hi. Sorry for what is perhaps a neophyte question: is it possible to pass a variable to a PHP script from inside another PHP piece of code? For instance, the file test.php (which of course...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.