Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Update Integer Field When Null Value Is Being Passed as Parameter

Posted on 2010-11-26
3
Medium Priority
?
696 Views
Last Modified: 2012-05-10
I have a drop down list in which the user can select blank(null), 1, 2, or 3.
I need to get the selected value of the drop down list and pass it as a parameter to update the database file.  The field that is being updated with this value is an integer.
Here is the code that I'm using:
 e.Command.Parameters("@Action_Priority").Value = ddlPriority.SelectedValue
How can I get this to work when the value is null????
0
Comment
Question by:mmtcunningham1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1000 total points
ID: 34217533
this should do;
if  ddlPriority.SelectedValue = "" then
 e.Command.Parameters("@Action_Priority").Value = DBNull.Value
else
 e.Command.Parameters("@Action_Priority").Value = ddlPriority.SelectedValue
end if

Open in new window

0
 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 34217605
yes "angelIII:" is 100% right.
0
 
LVL 32

Assisted Solution

by:Erick37
Erick37 earned 1000 total points
ID: 34217658
If the parameter of the stored procedure has a default value of NULL, then you do not even have to pass in the null value.

SQL Procedure:
Action_Priority INT = NULL  --Null is default

.NET:
if  ddlPriority.SelectedValue <> "" then
    e.Command.Parameters("@Action_Priority").Value = ddlPriority.SelectedValue
end if
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question