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 7604671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:58:22+00:00 2026-05-30T23:58:22+00:00

I am writing a statement which checks my database to see if a value

  • 0

I am writing a statement which checks my database to see if a value exists so that it does not insert a record to the database if it has the same unique ID. I have my exceptions working for the rest of my fields however I am having trouble retrieving data from the database to compare to the value I have caught from the database. Below is an example of my code.

int EmployeeIDCatched = int.Parse(employeeIDTextBox.Text);
var EmployeeIDQuery = from EmployeeID in EmployeeDataSet.Employee select EmployeeIDCatched;
if (EmployeeIDQuery.Equals(EmployeeIDCatched))

I was rather hoping someone might be able to correct this for me.

The dataset is called EmployeeDataSet, the table is called Employee and the row I am searching is called EmployeeID

If anyone could help I would be very grateful!

  • 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-05-30T23:58:24+00:00Added an answer on May 30, 2026 at 11:58 pm

    I’m assuming you want only one hit and you want the employee-object returned:

    int employeeIDCatched = int.Parse(employeeIDTextBox.Text);
    
    var matchingEmployee = (from employee in EmployeeDataSet.Employee
                            where employee.ID.Equals(employeeIDCatched)
                            select employee).FirstOrDefault();
    

    Update: Not sure if I didn’t read the question close enough or if the detail changed, but here is now to just get a bool-result:

    int employeeIDCatched = int.Parse(employeeIDTextBox.Text);
    
    bool hasMatchingEmployee = EmployeeDataSet.Employee.Any(employee =>
        employee.ID.Equals(employeeIDCatched));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a script which checks for a registry value and and exits
I have problem in some JavaScript that I am writing where the Switch statement
Writing a JSP page, what exactly does the <c:out> do? I've noticed that the
I am writing a stored procedure that works with a heavy select statement. The
I need help in writing the a case statement which will allow me to
I am having trouble writing a typeof statement which would be using a variable
When writing a switch statement, there appears to be two limitations on what you
As far as I know when writing a conditional statement in C such as
I'm writing a LINQ to SQL statement, and I'm after the standard syntax for
I have an ASP.NET site that I am maintaining. Currently it has code that

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.