473,385 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Checking for Null in Function ?

How can I check if dv recordcount isNull ?

Best Regards,

Luqman

Function showRecords(byVal ItemID as Int16) as String
Dim SqlArg as New DataSourceSelectArguments
Dim dv As New System.Data.DataView
dv=sqlDatasource.Select(SqlArg)

If dv.Item(0).Rows.Count.Equals(System.DBNull.Value) then Exit Function

Dim drRow asSystem.Data.DataRow=dv.Item(0).Row <---- Null Exception Error
in this Line

if drRow(0)>0 then
showRecords="yes"
End If

End Function


Apr 23 '07 #1
5 2302
On Apr 23, 12:19 pm, "luqman" <pearls...@cyber.net.pkwrote:
How can I check if dv recordcount isNull ?

Best Regards,

Luqman

Function showRecords(byVal ItemID as Int16) as String
Dim SqlArg as New DataSourceSelectArguments
Dim dv As New System.Data.DataView
dv=sqlDatasource.Select(SqlArg)

If dv.Item(0).Rows.Count.Equals(System.DBNull.Value) then Exit Function

Dim drRow asSystem.Data.DataRow=dv.Item(0).Row <---- Null Exception Error
in this Line

if drRow(0)>0 then
showRecords="yes"
End If

End Function
dv.Item(0).Rows.Count cannot be null

A dataview I suppose can be a null

but just check if number of rows is more than 0

If dv.Item(0).Rows.Count = 0 then Exit Function

Apr 23 '07 #2
Hi,

I also checked using If dv.Item(0).Rows.Count = 0 then Exit Function but
still its raising Null Exception.

Best Regards,

Luqman
"Alexey Smirnov" <al************@gmail.comwrote in message
news:11*********************@q75g2000hsh.googlegro ups.com...
On Apr 23, 12:19 pm, "luqman" <pearls...@cyber.net.pkwrote:
How can I check if dv recordcount isNull ?

Best Regards,

Luqman

Function showRecords(byVal ItemID as Int16) as String
Dim SqlArg as New DataSourceSelectArguments
Dim dv As New System.Data.DataView
dv=sqlDatasource.Select(SqlArg)

If dv.Item(0).Rows.Count.Equals(System.DBNull.Value) then Exit Function

Dim drRow asSystem.Data.DataRow=dv.Item(0).Row <---- Null Exception
Error
in this Line

if drRow(0)>0 then
showRecords="yes"
End If

End Function

dv.Item(0).Rows.Count cannot be null

A dataview I suppose can be a null

but just check if number of rows is more than 0

If dv.Item(0).Rows.Count = 0 then Exit Function

Apr 23 '07 #3
That can happen if you have no tables in your dataview.

You need to check earlier than your DV, or you could stick a try/catch
around this line.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"luqman" <pe*******@cyber.net.pkwrote in message
news:OF*************@TK2MSFTNGP06.phx.gbl...
Hi,

I also checked using If dv.Item(0).Rows.Count = 0 then Exit Function but
still its raising Null Exception.

Best Regards,

Luqman
"Alexey Smirnov" <al************@gmail.comwrote in message
news:11*********************@q75g2000hsh.googlegro ups.com...
>On Apr 23, 12:19 pm, "luqman" <pearls...@cyber.net.pkwrote:
How can I check if dv recordcount isNull ?

Best Regards,

Luqman

Function showRecords(byVal ItemID as Int16) as String
Dim SqlArg as New DataSourceSelectArguments
Dim dv As New System.Data.DataView
dv=sqlDatasource.Select(SqlArg)

If dv.Item(0).Rows.Count.Equals(System.DBNull.Value) then Exit Function

Dim drRow asSystem.Data.DataRow=dv.Item(0).Row <---- Null Exception
Error
in this Line

if drRow(0)>0 then
showRecords="yes"
End If

End Function

dv.Item(0).Rows.Count cannot be null

A dataview I suppose can be a null

but just check if number of rows is more than 0

If dv.Item(0).Rows.Count = 0 then Exit Function


Apr 23 '07 #4
Hi David,

Thanks a lot, I just figured out that I was not passing a parameter value to
my Sql Data Source.

Best Regards,

Luqman

"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:Ok**************@TK2MSFTNGP03.phx.gbl...
That can happen if you have no tables in your dataview.

You need to check earlier than your DV, or you could stick a try/catch
around this line.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"luqman" <pe*******@cyber.net.pkwrote in message
news:OF*************@TK2MSFTNGP06.phx.gbl...
Hi,

I also checked using If dv.Item(0).Rows.Count = 0 then Exit Function but
still its raising Null Exception.

Best Regards,

Luqman
"Alexey Smirnov" <al************@gmail.comwrote in message
news:11*********************@q75g2000hsh.googlegro ups.com...
On Apr 23, 12:19 pm, "luqman" <pearls...@cyber.net.pkwrote:
How can I check if dv recordcount isNull ?

Best Regards,

Luqman

Function showRecords(byVal ItemID as Int16) as String
Dim SqlArg as New DataSourceSelectArguments
Dim dv As New System.Data.DataView
dv=sqlDatasource.Select(SqlArg)

If dv.Item(0).Rows.Count.Equals(System.DBNull.Value) then Exit
Function

Dim drRow asSystem.Data.DataRow=dv.Item(0).Row <---- Null Exception
Error
in this Line

if drRow(0)>0 then
showRecords="yes"
End If

End Function

dv.Item(0).Rows.Count cannot be null

A dataview I suppose can be a null

but just check if number of rows is more than 0

If dv.Item(0).Rows.Count = 0 then Exit Function


Apr 23 '07 #5
On Apr 23, 1:24 pm, "David"
<david.colliver.N...@revilloc.REMOVETHIS.comwrot e:
That can happen if you have no tables in your dataview.

You need to check earlier than your DV, or you could stick a try/catch
around this line.

--
Best regards,
Dave Colliver.http://www.AshfieldFOCUS.com
~~http://www.FOCUSPortals.com- Local franchises available

"luqman" <pearls...@cyber.net.pkwrote in message

news:OF*************@TK2MSFTNGP06.phx.gbl...
Hi,
I also checked using If dv.Item(0).Rows.Count = 0 then Exit Function but
still its raising Null Exception.
Best Regards,
Luqman
"Alexey Smirnov" <alexey.smir...@gmail.comwrote in message
news:11*********************@q75g2000hsh.googlegro ups.com...
On Apr 23, 12:19 pm, "luqman" <pearls...@cyber.net.pkwrote:
How can I check if dv recordcount isNull ?
Best Regards,
Luqman
Function showRecords(byVal ItemID as Int16) as String
Dim SqlArg as New DataSourceSelectArguments
Dim dv As New System.Data.DataView
dv=sqlDatasource.Select(SqlArg)
If dv.Item(0).Rows.Count.Equals(System.DBNull.Value) then Exit Function
Dim drRow asSystem.Data.DataRow=dv.Item(0).Row <---- Null Exception
Error
in this Line
if drRow(0)>0 then
showRecords="yes"
End If
End Function
dv.Item(0).Rows.Count cannot be null
A dataview I suppose can be a null
but just check if number of rows is more than 0
If dv.Item(0).Rows.Count = 0 then Exit Function- Hide quoted text -

- Show quoted text -
Try to add this

If IsNothing(dv.Table) Then Exit Function

Note, that Exit Function will return nothing from your function.
Maybe it is better to Return String.Empty or any other value...

Apr 23 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Dave Robinson | last post by:
I was wondering if anyone could help me with a problem I'm having. I've been using Dreamweaver to create a hotel booking system for a friend of mine, using MySQL (version 4.0.21) and PHP 5. The...
30
by: Michael B Allen | last post by:
I have a general purpose library that has a lot of checks for bad input parameters like: void * linkedlist_get(struct linkedlist *l, unsigned int idx) { if (l == NULL) { errno = EINVAL;...
99
by: Mikhail Teterin | last post by:
Hello! Consider the following simple accessor function: typedef struct { int i; char name; } MY_TYPE; const char *
9
by: D. Shane Fowlkes | last post by:
(ASP.NET 2 / VB) Question - How can I write a If statement to see if a control (textbox) actually exists on a page? Upon page_load, a certain control may or may not be visible on the page so I...
4
by: Patient Guy | last post by:
Does anyone have any coding rules they follow when doing argument checking? When arguments fail during check, do you return from the call with an ambiguous return value, or do you throw...
10
by: mcbobin | last post by:
Hi, Here's hoping someone can help... I'm using a stored procedure to return a single row of data ie a DataRow e.g. public static DataRow GetManualDailySplits(string prmLocationID, string
42
by: =?Utf-8?B?UGxheWE=?= | last post by:
I have an if statement that isn't working correctly and I was wondering how I check for a blank string. My Code Example if me.fieldname(arrayIndex) = "" then ----- end if When I do this and...
1
by: kannan1983 | last post by:
In a table i have to check each and every column for null values . if the column has null value i need to display as ' NULL VALUE' in the output , for these iam declaring some local variables Iam...
8
by: aarklon | last post by:
Hi all, see:- http://linuxgazette.net/issue51/pramode.html
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.