Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Checking for empty set -- Oracle

Posted on 2006-06-13
1
Medium Priority
?
455 Views
Last Modified: 2012-05-05
Hi -

I'm having a little bit of a problem.
When the page loads a query is ran and populates the fields depending on the user name.
Sometimes it seems like the query doesn't even run.

I want to check to see if it is an empty set,
Then lblEmptySet.Text = "Empty"

Here is my code:

string mySelectQuery = "SELECT EMPLOYEE_NUMBER,START_DATE FROM BMDW_EMPLOYEE WHERE LAST_NAME ='" + lblLastName.Text.ToUpper() + "'";
                    string myConnString = "data source=*****;user id=******; password=******";
                    OracleConnection myDBConnection = new OracleConnection(myConnString);

                    OracleDataAdapter myAdapter = new OracleDataAdapter(mySelectQuery, myDBConnection);
                    myDBConnection.Open();
                    OracleDataReader myReader = myAdapter.SelectCommand.ExecuteReader();
                   
                    while (myReader.Read())
                    {
                        string EmpID = myReader["EMPLOYEE_NUMBER"].ToString();
                        lblEmpNum.Text = EmpID;

                        string strHireDate = myReader["START_DATE"].ToString();
                        txtHireDate.Text = strHireDate;
                    }

                    myDBConnection.Close();
0
Comment
Question by:JordanBlackler
[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
1 Comment
 
LVL 18

Accepted Solution

by:
Ravi Singh earned 2000 total points
ID: 16895880
Hi, try checking the HasRows property of the data reader:

...
if (myReader.HasRows)
{
      while (myReader.Read())
      {
           string EmpID = myReader["EMPLOYEE_NUMBER"].ToString();
           lblEmpNum.Text = EmpID;

           string strHireDate = myReader["START_DATE"].ToString();
           txtHireDate.Text = strHireDate;
       }
}
else
{
       lblEmptySet.Text = "Empty";
}
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
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…
Suggested Courses

604 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