Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8986621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:35:37+00:00 2026-06-15T21:35:37+00:00

we got this sql query: Select EmployeeDesignation from Employee where EmployeeName = Paramater1 (Parameter1

  • 0

we got this sql query:

Select EmployeeDesignation from Employee where EmployeeName = Paramater1 

(Parameter1 is value is passed to this)

We are using this statement:
lEmployeeDesignation = _SQLCommand.ExecuteScalar()

3 scenario’s:

  1. Returns the employee Designation (record exists in table)
  2. No value is set in database for Parameter1 – so should return NULL (record exists but has no value)
  3. No employee record exists so returns nothing (record doesn’t exists)

I’m struggling with 2 and 3 scenario – incase of Scenario 3 we want the application to fail, but struggling how to trap this error.
regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:35:38+00:00Added an answer on June 15, 2026 at 9:35 pm
    lEmployeeDesignation = _SQLCommand.ExecuteScalar()
    if lEmployeeDesignation IsNot Nothing AndAlso lEmployeeDesignation <> DBNull.Value then
        ' you have found your data....' 
    Else
        if lEmployeeDesignation = DBNull.Value then
           ' you have a record for parameter1 but EmployeeDesignation field is null'
        End If
    End If
    

    Notice the use of AndAlso to shortcircuit the evaluation process. If the first condition is false then the second one is not evaluated

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i got this SQL query where post_title taken from $_GET $sql = SELECT ID
I got this Sql Query declare @ProductNo int set @ProductNo = 123 select o.OrderNo,
I've got the next SQL query: SELECT FIRST_NAME, LAST_NAME FROM MYTABLE WHERE STATUS =
I've got this query: SELECT PICTURE FROM LOGO WHERE LOGONO = ? (PICTURE is
I have this sql query: $result = mysql_query(SELECT * FROM chat WHERE `to_id` =
I've got the SQL query below: SELECT message, sent_date, user_id FROM messages LEFT JOIN
As an input I've got a plain SQL query smth like: select * from
I got this: SET @databasename = (SELECT DATABASE()); USE @databasename; ...SQL Querys... But this
Following from this: Every specific weekday, sql and php I got this: deals_bookings.everyWeekDay =
I got this a problem, I need translate this SQL Query to Criteria, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.