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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:38:57+00:00 2026-05-29T06:38:57+00:00

This is working for me just fine. With if checks if dataset is empty

  • 0

This is working for me just fine. With if checks if dataset is empty or not. If so, return null value. But is the check of dataset right way or should i do some other way?

 da2 = new SqlDataAdapter("SELECT project_id FROM project WHERE _small_project_id = '" + cb_small_project.SelectedValue + "' ORDER BY NEWID()", conn);
 ds2 = new DataSet();
 da2.Fill(ds2);
 DataRow[] rowProject = dt2.Select();

 if (ds2.Tables[0].Rows.Count == 0)
    cmd.Parameters["@_project_id"].Value = guidNull;
 else
    cmd.Parameters["@_project_id"].Value = rowProject[0]["project_id"];
  • 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-29T06:38:57+00:00Added an answer on May 29, 2026 at 6:38 am

    In my opinion the ‘right’ way is to check both:

    ds2.Tables.Count 
    
    ds2.Tables[0].Rows.Count
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this: $(this).find('a:first'); and is working just fine to retrieve the URL of
Just for review, can someone quickly explain what prevents this from working (on compile):
I just ran across this error message while working in C# A property or
I just discovered this component and started working with it. I understand that the
I am working on const-correctness of my code and just wondered why this code
In my just-completed project, I was working getting distributed transactions working. We implemented this
I'm currently working on a critical monthly Accounts payable report. This report i just
Okay, this is just a minor caveat. I am currently working with the lovely
Strangely I had this working before but I reinstalled my system, upgraded to w7
This simple code checks if there is at lease one check box marked, When

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.