473,748 Members | 8,779 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Check for Datasource content

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

Thanks

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

Source Error:
Line 62: Dim myReader As SqlDataReader = cmd.ExecuteRead er()
Line 63: DGPages.DataSou rce = myReader
Line 64: If DGPages.DataSou rce <> "" Then
Line 65: DGPages.DataBin d()
Line 66: Else
Nov 19 '05 #1
4 1060
Source Error:
Line 62: Dim myReader As SqlDataReader = cmd.ExecuteRead er()
Line 63: DGPages.DataSou rce = myReader
Line 64: If DGPages.DataSou rce <> "" Then
Line 65: DGPages.DataBin d()
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.ExecuteRead er()
DGPages.DataSou rce = myReader
While myReader.Read()
If
'Check reader has content
Then
DGPages.DataBin d()
Else
lblNoContent.Vi sible = True
lblNoContent.Te xt = "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
34786
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 data from ADO.NET Datasets that are pre-populated by other modules of the application. What I need to do is to use these datasets as the datasources of my reports. Fine, I know how to do that and it works perfectly on my development box. The...
0
2632
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 Departments. Content pages are various Department reports listed in a TreeView control on the Master Page. From the content page in the VWD Configure Data Source wizard (which I love!), I was disappointed when adding a WHERE clause that the Control ID list...
3
2527
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 (which I love!), I was disappointed when adding a WHERE clause that the Control ID list in the wizard didn't include any of the Master Page controls. In the Design view, I can see the drop down list I want to use on the Master Page, shadowed and just...
5
2290
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 collection object -- say, a dictionary. Populating that collection object with custom objects, say, Person. What I really want to see is how to populate the properties of those Person objects from a datasource: instantiate one Person, fill...
4
2644
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 System.Web.SessionState; using System.Web.UI;
4
13490
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. I just set the GridView.DataSource once, and call DataBind(); I'd like to drive the application from the GridView control, by including command buttons that allow editing of the data. Starting out simple, I have a DataTable with a boolean...
1
8303
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 program use. But instead of Updating the ListBox, virtually nothing happens. The items that were written into the ListBox during the first run remain inside the ListBox, assuming the new values of the ArrayList. Obviously, if the new ArrayList is...
2
11581
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 void loadBytes(InputStream is){ DataSource ds=new DataSource(is); player = Manager.createPlayer(ds);
0
3488
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 datasource import java.awt.BorderLayout; import java.awt.Component; import java.io.*; import java.net.URL; import javax.media.*;
0
8989
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9243
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.