Can someone please tell me what is wrong with the following code!
I have a record in the datareader but it isn't showing up and niether is the
label... I presume there is a problem with this code!
Thanks
...CODE..
Dim myReader As SqlDataReader = cmd.ExecuteRead er()
Dim hasRows As Boolean
hasRows = False
DGPages.DataSou rce = myReader
While myReader.Read()
hasRows = True
If hasRows = True Then
DGPages.DataBin d()
ElseIf hasRows = False Then
lblNoContent.Vi sible = True
lblNoContent.Te xt = "There a currently no pages for"
End If
End While
myReader.Close( ) 5 1203
Hi,
I never really tested this, but my guess would be as follows:
Since DataReaders are forward only, your call to DataReader.Read is moving
the reader cursor forward, then
when you call the DataBind method it will also cause the DataGrid to move
through the same reader, which has already moved on to the next record. In
your case there is no next record so the DataGrid is empty.
Hope this helps
--
Chris Taylor http://dotnetjunkies.com/weblog/chris.taylor
"Tim::.." <myatix_at_hotm ail.com> wrote in message
news:14******** *************** ***********@mic rosoft.com... Can someone please tell me what is wrong with the following code!
I have a record in the datareader but it isn't showing up and niether is
the label... I presume there is a problem with this code!
Thanks
..CODE.. Dim myReader As SqlDataReader = cmd.ExecuteRead er() Dim hasRows As Boolean hasRows = False DGPages.DataSou rce = myReader While myReader.Read() hasRows = True If hasRows = True Then DGPages.DataBin d() ElseIf hasRows = False Then lblNoContent.Vi sible = True lblNoContent.Te xt = "There a currently no pages for" End If End While
myReader.Close( )
OK... Got it and I think you are right but any ideas on how to get around
this issue???
Thanks
"Chris Taylor" wrote: Hi,
I never really tested this, but my guess would be as follows: Since DataReaders are forward only, your call to DataReader.Read is moving the reader cursor forward, then when you call the DataBind method it will also cause the DataGrid to move through the same reader, which has already moved on to the next record. In your case there is no next record so the DataGrid is empty.
Hope this helps
-- Chris Taylor http://dotnetjunkies.com/weblog/chris.taylor "Tim::.." <myatix_at_hotm ail.com> wrote in message news:14******** *************** ***********@mic rosoft.com... Can someone please tell me what is wrong with the following code!
I have a record in the datareader but it isn't showing up and niether is the label... I presume there is a problem with this code!
Thanks
..CODE.. Dim myReader As SqlDataReader = cmd.ExecuteRead er() Dim hasRows As Boolean hasRows = False DGPages.DataSou rce = myReader While myReader.Read() hasRows = True If hasRows = True Then DGPages.DataBin d() ElseIf hasRows = False Then lblNoContent.Vi sible = True lblNoContent.Te xt = "There a currently no pages for" End If End While
myReader.Close( )
This is just a guess because I don't write VB
Dim myReader As SqlDataReader = cmd.ExecuteRead er()
Dim hasRows As Boolean
hasRows = False
DGPages.DataSou rce = myReader
DGPages.DataBin d()
If DGPages.Rows.Co unt = 0 Then
lblNoContent.Vi sible = True
lblNoContent.Te xt = "There a currently no pages for"
End If
myReader.Close( )
Chris is right, what you're doing is binding the datagrid repeatedly to the
datareader. For every row of the datareader you are calling the databind
method, thus constantly updating the grid. You don't have to ever call the
read method when you are binding directly to the datareader. If you're using
ASP.Net 1.1, There is already a HasRows property for the datareader that you
can check and avoid the other steps alltogether. Just check the hasrows
property of the datareader then bind if true. Just don't call the read
method before binding as that will read the first row.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
"Tim::.." <myatix_at_hotm ail.com> wrote in message
news:14******** *************** ***********@mic rosoft.com... Can someone please tell me what is wrong with the following code!
I have a record in the datareader but it isn't showing up and niether is the label... I presume there is a problem with this code!
Thanks
..CODE.. Dim myReader As SqlDataReader = cmd.ExecuteRead er() Dim hasRows As Boolean hasRows = False DGPages.DataSou rce = myReader While myReader.Read() hasRows = True If hasRows = True Then DGPages.DataBin d() ElseIf hasRows = False Then lblNoContent.Vi sible = True lblNoContent.Te xt = "There a currently no pages for" End If End While
myReader.Close( ) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sarah Tanembaum |
last post by:
Beside its an opensource and supported by community, what's the fundamental
differences between PostgreSQL and those high-price commercial database (and
some are bloated such as Oracle) from software giant such as Microsoft SQL
Server, Oracle, and Sybase?
Is PostgreSQL reliable enough to be used for high-end commercial
application? Thanks
|
by: titan0111 |
last post by:
#include<iostream>
#include<iomanip>
#include<cstring>
#include<fstream>
using namespace std;
class snowfall
{
private:
int ft;
|
by: E. Robert Tisdale |
last post by:
What makes a good C/C++ programmer?
Would you be surprised if I told you that
it has almost nothing to do with your knowledge of C or C++?
There isn't much difference in productivity, for example,
between a C/C++ programmers with a few weeks of experience
and a C/C++ programmer with years of experience.
You don't really need to understand the subtle details
or use the obscure features of either language
|
by: typingcat |
last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so
on. I've tried many PHP IDEs today, but almost non of them supported
Unicode (UTF-8) file.
I've found that the only Unicode support IDEs are DreamWeaver 8 and
Zend PHP Studio.
DreamWeaver provides full support for Unicode. However, DreamWeaver is
a web editor rather than a PHP IDE. It only supports basic IntelliSense
(or code completion) and doesn't have anything...
|
by: Madhur |
last post by:
Hello
what about this nice way to open a file in single line rather than using
if and else.
#include<stdio.h>
void main()
{
FILE *nd;
clrscr();
fopen("c:\\autoexec.bat","r")&&printf("success") || printf("error opeing
| |
by: Cherrish Vaidiyan |
last post by:
Frinds,
Hope everyone is doing fine.i feel pointers to be the most toughest
part in C. i have just completed learning pointers & arrays related
portions. I need to attend technical interview on C. wat type of
questions should be expected? Which part of C language do the staff
give more concern?
The interviewers have just mentioned that .. i will have interview on
C.
Also can anyone can help me with sites where i can go thru sample
|
by: Keith K |
last post by:
Having developed with VB since 1992, I am now VERY
interested in C#. I've written several applications with
C# and I do enjoy the language.
What C# Needs:
There are a few things that I do believe MSFT should do to
improve C#, however.
I know that in the "Whidbey" release of VS.NET currently
|
by: Jason Huang |
last post by:
Hi,
Would someone explain the following coding more detail for me? What's the
( ) for?
CurrentText = (TextBox)e.Item.Cells.Controls;
Thanks.
Jason
|
by: Pyenos |
last post by:
import cPickle, shelve
could someone tell me what things are wrong with my code?
class progress:
PROGRESS_TABLE_ACTIONS=
DEFAULT_PROGRESS_DATA_FILE="progress_data"
PROGRESS_OUTCOMES=
|
by: Siong.Ong |
last post by:
Dear all,
my PHP aims to update a MySQL database by selecting record
one by one and modify then save.
Here are my PHP, but I found that it doesnt work as it supposed to be,
for example, when Record (i) is shown and modified, the change will
come to Record (i+1).
Can anyone provide suggestion?
thanks.
|
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...
| |
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,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
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...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |