473,387 Members | 1,502 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,387 software developers and data experts.

Check for Datasource content

Can someone tell me what operator I use to check if the datasource has any
content?

Thanks

Exception Details: System.InvalidCastException: Operator is not valid for
type 'SqlDataReader' and string "".

Source Error:
Line 62: Dim myReader As SqlDataReader = cmd.ExecuteReader()
Line 63: DGPages.DataSource = myReader
Line 64: If DGPages.DataSource <> "" Then
Line 65: DGPages.DataBind()
Line 66: Else
Nov 19 '05 #1
4 1040
Source Error:
Line 62: Dim myReader As SqlDataReader = cmd.ExecuteReader()
Line 63: DGPages.DataSource = myReader
Line 64: If DGPages.DataSource <> "" Then
Line 65: DGPages.DataBind()
Line 66: Else


I think....just off the top of my head.... that I would do a.....

Line 66: if myReader.Read then

Nov 19 '05 #2
Oh damn me, i meant for that to be LINE 64!!
Nov 19 '05 #3
That doesn't really solve what I'm trying to do... I don't think! Here is the
code! I need to see if the reader has content and if not then write a
message...

Dim myReader As SqlDataReader = cmd.ExecuteReader()
DGPages.DataSource = myReader
While myReader.Read()
If
'Check reader has content
Then
DGPages.DataBind()
Else
lblNoContent.Visible = True
lblNoContent.Text = "There a currently no pages for' &
FindOffice()"
End If
End While
Nov 19 '05 #4
> I need to see if the reader has content and if not then write a
message...


The code i posted:

...if myReader.Read then...

....actually tries to read data from the database.
If there is no data, the myReader.Read call returns a "false",
and if there _is_ data to read, it returns "true".

So this should work:

if myReader.Read then
myGrid.databind()
else
msgbox("There's no data to read!")
end if

Jeppe Jespersen
Nov 19 '05 #5

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

Similar topics

7
by: TJoker .NET | last post by:
I'm developing an VB.NET Windows Forms application that uses CR for VS.NET (original version shipped with VS.NET 2002 - my VS.NET has the latest SP installed, no SPs for CR). My reports get their...
0
by: David | last post by:
In ASP.NET 2.0, is it possible to use a control that's on a Master Page as a select parameter in a content page's datasource control? For example, the Master Page has a drop down list of...
3
by: David | last post by:
In ASP.NET 2.0, is it possible to use a control that's on a Master Page as a select parameter in a content page's datasource control? On the content page in the VWD Configure Data Source wizard...
5
by: | last post by:
Trying to learn about manipulating collections of objects, and populating these objects dynamically from datasources. Could someone post a code sample that shows the following: Instantiating a...
4
by: Nu2ASP.NET | last post by:
I have the following code in my code behind page: using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using...
4
by: Jim Katz | last post by:
I have an application that updates a strongly typed data set at run time. I'd like to dynamically create a table that connects to a run time data table. For displaying the data, this works well. ...
1
by: Refugnic | last post by:
I tried to fill a ListBox with a DataSource pointing to an ArrayList. It all works fine...up to one point. The ArrayList is dynamic, which means the contents of it change, during the course of...
2
by: shahiz | last post by:
basically im having null pointer exception //read an inputstream is = new DataInputStream(new FileInputStream("test.mpg")); loadBytes(is); //pass it as a datasource for the player public...
0
by: shahiz | last post by:
This the error i get when i try to run my program Error: Unable to realize com.sun.media.amovie.AMController@18b81e3 Basically i have a mediapanel class that initialize and play the media as...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.