c#


Rows.Count = 1 when returned dataset consists of an empty row


My query does not return anything but an empty row, since there is no records that meet all the criteria of my query. However, Rows.Count is 1 instead of 0. Here is my query:
SELECT LicenseID
FROM LICENSES
WHERE LicenseType = #LicenseType
AND DriverID = #DriverID
AND CarID IN(
SELECT CarID
FROM CARS
WHERE CarSerial = #CarSerial
AND DriverID = #DriverID
) AND LicenseID IS NOT NULL
AND ((StartDate <= CONVERT(DATETIME, #EndDate))
AND (EndDate >= CONVERT(DATETIME, #StartDate)))
Here is my C# if statement condition that for some reason keeps being true due to row count, even though there is no record meeting criteria:
if (ds != null && ds.Tables[0].Rows.Count > 0)
The database used is SQL Server. This previously seemed to work correctly under Oracle.
To Avoid ERROR:
if (ds.Tables.Count > 0)
{
if (ds.Tables[0].Rows.Count > 0)
{
//Then Return a value here or Get the date
foreach (DataRow dr in ds.Tables[0].Rows)
{
String getFirstRow = dr[0].ToString();
//And so on........
}
}
else
{
//Return value if no rows found.
}
}
what I needed to add was just an additional check for "LicenseID <> ''". "LicenseID IS NOT NULL" was not enough since there has been a record meeting all criteria but having LicenseID = "". I believe this has not been an issue with Oracle database, but turned out to be an issue after switching to SQL Server. Thanks for all your comments and suggestions.

Related Links

Checking client side validation suceeded/failed at server side
How to efficiently make changes to code (removing defunct code)
What is the recommended way to assign and change an event for button on a form
Display, Connect and Disconnect Wireless Networks
Converting Java Generics to C# Generics
C# - HttpWebResponse Header Not Being Set
How can I instantiate this class?
How do I set the Manager Attribute on the UserPrincipal object in Active Directory in C#
using PreSendRequestHeaders Event in global.asax
Assign to class property from XML randomly
Second Level Property Binding exception on Win XP(x86) OS but not Win 7(x64)
Support for multilanguage in ASP.NET
LINQ Select a List of List with DISTINCT
WPF 'Map' control; using canvas to display lots of bitmap images
Event accessing Bitmap while its locked
Is it possible to select the sum of a column, grouping by another column?

Categories

HOME
stanford-nlp
locale
cxf
android-ndk
liquibase
azure-database-mysql
ms-application-insights
sdk
schema
google-api-oauth
annyang
software-collections
google-search-appliance
dynamics-crm-2011
xmlhttprequest
repeater
reportlab
wallet
alert
minimagick
include-path
multipart
gnu-screen
screen-scraping
concatenation
struts
scrapy-spider
android-xml
utc
multiple-inheritance
javapns
kundera
multilanguage
geocomplete
abide
oracle-bpm-suite
yelp
framebuffer
motion
armadillo
rbac
susy
vertical-alignment
redbean
mtm
vpython
python-venv
weld
angular-fullstack
spring-webflow-2
ionic2-select
vertex
node-java
cc
totalview
robotc
catalyst
glade
consolidation
settext
netlink
instaparse
init
key-value-store
window.location
mod
paypal-subscriptions
ideavim
opendolphin
skscene
jain-sip
om
pushwoosh
android-filterable
tokudb
opennebula
jsonmodel
javadb
illegalargumentexception
os.walk
growl
powerpoint-2010
pnunit
webshim
traceur
image-preloader
power-management
.net-reflector
friendly-id
cab
forward-declaration
panelgrid
google-checkout
wordbreaker
coinbase-php
m3u
ios6-maps
systrace
motorola-droid
unordered-set
httppostedfilebase
onunload
virtual-destructor
chars
simultaneous
webdb
wtsapi32

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App