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

JWT code examples
How do I create a windows service for authentication that custom web applications can use to authenticate AD users?
Testing if ASP Table is Visible
Get list of tables from database
C# control.find explanation
Creating executable COM as ATL project and use it in C#
Supress all violations in Code Analysis Visual studio 2015
How to Save contents of a textbox to a file
Managing Arrays in C# (Memory management)
ASP.NET Web API: any downsides to asynchronous operations?
Use Debug.Log from C++
Comparing only time element with Oracle db using Entity Framework
WebAPI - return file and additional data
Get RMS from FFT
When Include() executing in Entity Framework?
How to save accesstoken to string from API (C# Xamarin Studio)

Categories

HOME
excel-formula
url
grpc
window.open
magento-1.9.2.1
okhttp3
download
css-selectors
psexec
opacity
segmentation-fault
cracking
digital
urllib2
point-of-sale
websharper
fine-uploader
expo
derby
appsettings
luis
vivado-hls
geography
glibc
gomobile
minimagick
android-navigation-drawer
lotusscript
pushbullet
android-cursorloader
cloudformation
spock
kundera
kubectl
postgresql-9.6
luhn
http-proxy
maven-2
redhat-brms
instances
ngrok
usernotifications
office-interop
keychain
autodesk-data-management
colorbox
g77
evaluation
monaca
skype-bots
nsalert
bipartite
acceleo
nls
zsh-completion
toggleclass
alfred
dimensionality-reduction
konakart
nimbus
angularfire
php-java-bridge
web-optimization
hana-sql-script
bluetooth-lowenergy-4.2
videoview
imageicon
producer-consumer
serial-communication
traminer
log4cxx
nmock
android-networking
vectordrawable
fileinputstream
screen-lock
caption
xcode5
aiff
system.io.packaging
xmlserializer
nsnotificationcenter
pnunit
yandex-api
lettuce
html5-filesystem
facebook-java-api
xtify
grunt-wiredep
thucydides
google-voice
ironworker
exi
gpl
antixsslibrary
junit-rule
php-gettext
jquery-ui-map
github-archive
commonsware
vectorwise
quazip
s60
chars
nstoolbar
mdd
dojox.gfx
focus-stealing
projectgen
cstring

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