Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to check for the datagrid datasource to be null

Posted on 2004-10-25
5
Medium Priority
?
410 Views
Last Modified: 2008-02-01
I have a datagrid which populates at runtime and then I use

dataView = ctype(datagrid.datasource, DataView)
if dataview.count = 0 then
.....

at "if...." I am getting null reference. How to check for the datasource is present or not.

Reddy

0
Comment
Question by:angireddy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 10

Accepted Solution

by:
james-ct16 earned 1500 total points
ID: 12401136
hi
way i do it is with an additional if

if not (dataview is nothing) then
'data avaiable
else
'no data
end if



in addition to this you could as feel as an eliment of good form you could just catch teh error and handle it through the try catch statement

regards

james
0
 
LVL 6

Expert Comment

by:KGreg
ID: 12401142
If NOT Datagrid.Datasource IS Nothing then

   ' The datasource is not null

ELSE

  ' The datasource is null

END IF



KGREG
0
 
LVL 6

Expert Comment

by:KGreg
ID: 12401153
I wouldn't use a try catch on this.  That could be a performance hit.  The best way is to check that the object is not "Nothing"

KGREG
0
 
LVL 6

Expert Comment

by:KGreg
ID: 12401166
Save the Try Blocks for "exceptional" cases.  If you can check for the condition very easily, do it - if not - then it should be caught.. like a server going down during a transaction, or a device failing, etc.

KGREG
0
 

Author Comment

by:angireddy
ID: 12401198
thankyou KREG, that was valuable information

reddy
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question