Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Determing number of records in a table in a Dataset?


Message #1 by "Lists, IT" <ITLists@l...> on Wed, 10 Jul 2002 08:47:02 -0700
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C22829.08FE9F30
Content-Type: text/plain;
	charset="iso-8859-1"

Populating a dataset with one table w/ a datadapter. I want to check the
number of records put into that table such that if there's 0 I can set the
text value of a label to "No records returned!" so the user is shown
something (b/c the Repeater control will be empty due to no records.

Any tips? Thanks!

Wells Oliver
Web Application Programmer
Leviton Voice & Data
xxx-xxx-xxxx
http://www.levitonvoicedata.com 

Message #2 by "Lewis" <lewis@t...> on Wed, 10 Jul 2002 10:12:38 -0600
This is a multi-part message in MIME format.

------=_NextPart_000_0006_01C227FA.51F42FE0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Determing number of records in a table in a Dataset?dim ds as dataset

(code to create the dataset...)

if ds.count <= 0 then
    ' no records found
else
    ' found records
end if
  -----Original Message-----
  From: Lists, IT [mailto:ITLists@l...]
  Sent: Wednesday, July 10, 2002 9:47 AM
  To: ASP+
  Subject: [aspx] Determing number of records in a table in a Dataset?


  Populating a dataset with one table w/ a datadapter. I want to check the
number of records put into that table such that if there's 0 I can set the
text value of a label to "No records returned!" so the user is shown
something (b/c the Repeater control will be empty due to no records.

  Any tips? Thanks!

  Wells Oliver
  Web Application Programmer
  Leviton Voice & Data
  xxx-xxx-xxxx
  http://www.levitonvoicedata.com

  --- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 


Message #3 by "Lists, IT" <ITLists@l...> on Wed, 10 Jul 2002 09:13:57 -0700
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C2282C.CBA0CBA0
Content-Type: text/plain;
	charset="iso-8859-1"

Thanks! While I'm on the subject, another DataSet question.
 
_How_ do I update records in a dataset (without manipulating the original
datasource)? I think I am missing something easy here.
 
Example: I retrieve a bunch of rows from a DB and stick them in a dataset in
a table called "Forums". I want to then update that table and set everything
to "None" where the field is null. The SQL command is "UPDATE Forums SET
FORUMLASTPOST = 'None' WHERE FORUMLASTPOST IS NULL".
 
I am just missing how to go about affecting the table in the dataset like
this.
 
Any info appreciated-- thanks!

-----Original Message-----
From: Lewis [mailto:lewis@t...]
Sent: Wednesday, July 10, 2002 9:13 AM
To: ASP+
Subject: [aspx] RE: Determing number of records in a table in a Dataset?


dim ds as dataset
 
(code to create the dataset...)
 
if ds.count <= 0 then
    ' no records found
else
    ' found records
end if

-----Original Message-----
From: Lists, IT [mailto:ITLists@l...]
Sent: Wednesday, July 10, 2002 9:47 AM
To: ASP+
Subject: [aspx] Determing number of records in a table in a Dataset?



Populating a dataset with one table w/ a datadapter. I want to check the
number of records put into that table such that if there's 0 I can set the
text value of a label to "No records returned!" so the user is shown
something (b/c the Repeater control will be empty due to no records.

Any tips? Thanks! 

Wells Oliver 
Web Application Programmer 
Leviton Voice & Data 
xxx-xxx-xxxx 
http://www.levitonvoicedata.com <http://www.levitonvoicedata.com>  

--- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to  

--- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to  


Message #4 by "Garland Frye" <gfrye@s...> on Wed, 10 Jul 2002 11:25:34 -0500
This is a multi-part message in MIME format.

------=_NextPart_000_000D_01C22804.822ECA80
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Determing number of records in a table in a Dataset?Actually this is 
incorrect, a dataset is not a collection of records, it is a collection 
of tables...

To determine the record cound you must index into the row collection, of 
the desired table.

DataSet.Tables("tablename").Rows.Count

This is the property you need to be looking for.

Thanks,
Garland
  "Lists, IT" <ITLists@l...> wrote in message 
news:192217@a...
  Thanks! While I'm on the subject, another DataSet question.

  _How_ do I update records in a dataset (without manipulating the 
original datasource)? I think I am missing something easy here.

  Example: I retrieve a bunch of rows from a DB and stick them in a 
dataset in a table called "Forums". I want to then update that table and 
set everything to "None" where the field is null. The SQL command is 
"UPDATE Forums SET FORUMLASTPOST =3D 'None' WHERE FORUMLASTPOST IS 
NULL".

  I am just missing how to go about affecting the table in the dataset 
like this.

  Any info appreciated-- thanks!
    -----Original Message-----
    From: Lewis [mailto:lewis@t...]
    Sent: Wednesday, July 10, 2002 9:13 AM
    To: ASP+
    Subject: [aspx] RE: Determing number of records in a table in a 
Dataset?


    dim ds as dataset

    (code to create the dataset...)

    if ds.count <=3D 0 then
        ' no records found
    else
        ' found records
    end if
      -----Original Message-----
      From: Lists, IT [mailto:ITLists@l...]
      Sent: Wednesday, July 10, 2002 9:47 AM
      To: ASP+
      Subject: [aspx] Determing number of records in a table in a 
Dataset?


      Populating a dataset with one table w/ a datadapter. I want to 
check the number of records put into that table such that if there's 0 I 
can set the text value of a label to "No records returned!" so the user 
is shown something (b/c the Repeater control will be empty due to no 
records.

      Any tips? Thanks!

      Wells Oliver
      Web Application Programmer
      Leviton Voice & Data
      xxx-xxx-xxxx
      http://www.levitonvoicedata.com

      --- 
    --- 


Message #5 by "Garland Frye" <gfrye@s...> on Wed, 10 Jul 2002 11:35:33 -0500
This is a multi-part message in MIME format.

------=_NextPart_000_0019_01C22805.E6DEE4F0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Determing number of records in a table in a Dataset?To work with your 
dataset you should do something like this

Dim dr As DataRow
Dim n As Integer

For each dr in DataSet.dt.rows
    For n =3D 0 to dt.rows.count - 1
        if dr(n) =3D DbType.DBNull.Value then        '******See footnote
            dr(n) =3D "Nothing"
    Next n
Next dr


******if using SQL Server, use SqlTypes.Null in the place of DBNull

Thanks,
Garland
  "Lists, IT" <ITLists@l...> wrote in message 
news:192217@a...
  Thanks! While I'm on the subject, another DataSet question.

  _How_ do I update records in a dataset (without manipulating the 
original datasource)? I think I am missing something easy here.

  Example: I retrieve a bunch of rows from a DB and stick them in a 
dataset in a table called "Forums". I want to then update that table and 
set everything to "None" where the field is null. The SQL command is 
"UPDATE Forums SET FORUMLASTPOST =3D 'None' WHERE FORUMLASTPOST IS 
NULL".

  I am just missing how to go about affecting the table in the dataset 
like this.

  Any info appreciated-- thanks!
    -----Original Message-----
    From: Lewis [mailto:lewis@t...]
    Sent: Wednesday, July 10, 2002 9:13 AM
    To: ASP+
    Subject: [aspx] RE: Determing number of records in a table in a 
Dataset?


    dim ds as dataset

    (code to create the dataset...)

    if ds.count <=3D 0 then
        ' no records found
    else
        ' found records
    end if
      -----Original Message-----
      From: Lists, IT [mailto:ITLists@l...]
      Sent: Wednesday, July 10, 2002 9:47 AM
      To: ASP+
      Subject: [aspx] Determing number of records in a table in a 
Dataset?


      Populating a dataset with one table w/ a datadapter. I want to 
check the number of records put into that table such that if there's 0 I 
can set the text value of a label to "No records returned!" so the user 
is shown something (b/c the Repeater control will be empty due to no 
records.

      Any tips? Thanks!

      Wells Oliver
      Web Application Programmer
      Leviton Voice & Data
      xxx-xxx-xxxx
      http://www.levitonvoicedata.com

      --- 
    --- 


Message #6 by Feduke Cntr Charles R <FedukeCR@m...> on Wed, 10 Jul 2002 12:36:56 -0400
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C22830.017A2AC0
Content-Type: text/plain;
	charset="iso-8859-1"

    If you're doing web stuff, is there any need for the DataSet?  If you're
not explicitly doing work with DataRelations and child tables or storing the
DataSet in your Session collection, then I recommend you use a DataReader
instead.  You can do what you what by setting the text of your label to "No
records returned!" in your *.aspx file and do something similiar to the
following (for reference, "count" is the name of the label control):
 
---
OleDbDataReader dr = someOleDbCommand.Execute("whatever SQL");
// DataReaders start at BOF and return true on a successful
// .Read()
if (dr.Read())
{
    // hide the label (or change the text)
    count.Visible = false;
    do
    {
        // write information to a StringBuilder
        // to assign to a literal instead of the 
        // DataRepeater here, or put it into an
        // array to assign to the DataRepeater
    } while (dr.Read()); // we use do... while because the 
        // if statement already got our first record
}
 
    Of course if you want to use a DataSet because its easier (I just wanted
to impart the above knowledge cuz I love DataReaders and they make perfect
sense in web applications) then you can do:
 
count.Visible = (ds["table"].Rows.Count == 0)
 
HTH,
- Chuck
 
 

-----Original Message-----
From: Lists, IT [mailto:ITLists@l...]
Sent: Wednesday, July 10, 2002 11:47 AM
To: ASP+
Subject: [aspx] Determing number of records in a table in a Dataset?



Populating a dataset with one table w/ a datadapter. I want to check the
number of records put into that table such that if there's 0 I can set the
text value of a label to "No records returned!" so the user is shown
something (b/c the Repeater control will be empty due to no records.

Any tips? Thanks! 

Wells Oliver 
Web Application Programmer 
Leviton Voice & Data 
xxx-xxx-xxxx 
http://www.levitonvoicedata.com <http://www.levitonvoicedata.com>  

--- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to  


Message #7 by Feduke Cntr Charles R <FedukeCR@m...> on Wed, 10 Jul 2002 12:40:33 -0400
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C22830.82771A20
Content-Type: text/plain;
	charset="iso-8859-1"

    And if you're using MS Access you could do the leg work in the Jet
driver:
 
"SELECT name, id, IIf([ForumLastPost] = NULL, "None", [ForumLastPost]) AS
ForumLastPost FROM table ORDER BY name"
 
    There are similiar methods of doing this in both Oracle and SQL Server.
You might find it easier and efficient to let the RDBMS do some of this work
rather than iterating your DataSet to add values before its iterated again
for display.
 
- Chuck

-----Original Message-----
From: Lists, IT [mailto:ITLists@l...]
Sent: Wednesday, July 10, 2002 12:14 PM
To: ASP+
Subject: [aspx] RE: Determing number of records in a table in a Datase t?


Thanks! While I'm on the subject, another DataSet question.
 
_How_ do I update records in a dataset (without manipulating the original
datasource)? I think I am missing something easy here.
 
Example: I retrieve a bunch of rows from a DB and stick them in a dataset in
a table called "Forums". I want to then update that table and set everything
to "None" where the field is null. The SQL command is "UPDATE Forums SET
FORUMLASTPOST = 'None' WHERE FORUMLASTPOST IS NULL".
 
I am just missing how to go about affecting the table in the dataset like
this.
 
Any info appreciated-- thanks!

-----Original Message-----
From: Lewis [mailto:lewis@t...]
Sent: Wednesday, July 10, 2002 9:13 AM
To: ASP+
Subject: [aspx] RE: Determing number of records in a table in a Dataset?


dim ds as dataset
 
(code to create the dataset...)
 
if ds.count <= 0 then
    ' no records found
else
    ' found records
end if

-----Original Message-----
From: Lists, IT [mailto:ITLists@l...]
Sent: Wednesday, July 10, 2002 9:47 AM
To: ASP+
Subject: [aspx] Determing number of records in a table in a Dataset?



Populating a dataset with one table w/ a datadapter. I want to check the
number of records put into that table such that if there's 0 I can set the
text value of a label to "No records returned!" so the user is shown
something (b/c the Repeater control will be empty due to no records.

Any tips? Thanks! 

Wells Oliver 
Web Application Programmer 
Leviton Voice & Data 
xxx-xxx-xxxx 
http://www.levitonvoicedata.com <http://www.levitonvoicedata.com>  

--- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to  

--- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to  

--- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to  


Message #8 by "Lists, IT" <ITLists@l...> on Wed, 10 Jul 2002 09:45:19 -0700
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C22831.2CEE79D0
Content-Type: text/plain;
	charset="iso-8859-1"

Thanks! One problem:
 
Compiler Error Message: BC30456: 'null' is not a member of 'SqlTypes'.
 
Code block is:
 
  for each dr in dsBoards.Tables("Forums").Rows
   for x = 0 to dsBoards.Tables("Forums").rows.count - 1
    if (dr(x)) = sqlTypes.null Then
     dr(x) = "None"
    end if
   next x
  next dr
 
any idea? I also tried for the sake of testing sqlTypes.dbNull; no go.

-----Original Message-----
From: Garland Frye [mailto:gfrye@s...]
Sent: Wednesday, July 10, 2002 9:36 AM
To: ASP+
Subject: [aspx] Re: Determing number of records in a table in a Datase t?


To work with your dataset you should do something like this
 
Dim dr As DataRow
Dim n As Integer
 
For each dr in DataSet.dt.rows
    For n = 0 to dt.rows.count - 1
        if dr(n) = DbType.DBNull.Value then        '******See footnote
            dr(n) = "Nothing"
    Next n
Next dr
 
 
******if using SQL Server, use SqlTypes.Null in the place of DBNull
 
Thanks,
Garland


Message #9 by "Garland Frye" <gfrye@s...> on Wed, 10 Jul 2002 12:03:20 -0500
This is a multi-part message in MIME format.

------=_NextPart_000_0009_01C22809.C8C251B0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Determing number of records in a table in a Dataset?My mistake, use 
DBNull.Value

Thanks,
Garland
  "Lists, IT" <ITLists@l...> wrote in message 
news:192240@a...
  Thanks! One problem:

  Compiler Error Message: BC30456: 'null' is not a member of 'SqlTypes'.

  Code block is:

    for each dr in dsBoards.Tables("Forums").Rows
     for x =3D 0 to dsBoards.Tables("Forums").rows.count - 1
      if (dr(x)) =3D sqlTypes.null Then
       dr(x) =3D "None"
      end if
     next x
    next dr

  any idea? I also tried for the sake of testing sqlTypes.dbNull; no go.
    -----Original Message-----
    From: Garland Frye [mailto:gfrye@s...]
    Sent: Wednesday, July 10, 2002 9:36 AM
    To: ASP+
    Subject: [aspx] Re: Determing number of records in a table in a 
Datase t?


    To work with your dataset you should do something like this

    Dim dr As DataRow
    Dim n As Integer

    For each dr in DataSet.dt.rows
        For n =3D 0 to dt.rows.count - 1
            if dr(n) =3D DbType.DBNull.Value then        '******See 
footnote
                dr(n) =3D "Nothing"
        Next n
    Next dr


    ******if using SQL Server, use SqlTypes.Null in the place of DBNull

    Thanks,
    Garland


Message #10 by "Oliver, Wells" <WOliver@l...> on Wed, 10 Jul 2002 10:04:02 -0700
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C22833.CA8B11B0
Content-Type: text/plain;
	charset="iso-8859-1"

Hmm:
 
Compiler Error Message: BC31080: Operator '=' is not defined for types
'System.Object' and 'System.DBNull'. Use 'Is' operator to compare two
reference types.

  for each dr in dsBoards.Tables("Forums").Rows
   for x = 0 to dsBoards.Tables("Forums").rows.count - 1
    if (dr(x) = dbNull.value) Then
     dr(x) = "None"
    end if
   next x
  next dr


-----Original Message-----
From: Garland Frye [mailto:gfrye@s...]
Sent: Wednesday, July 10, 2002 10:03 AM
To: ASP+
Subject: [aspx] Re: Determing number of records in a table in a Datase t?


My mistake, use DBNull.Value
 
Thanks,
Garland

"Lists, IT" < ITLists@l...
<mailto:ITLists@l...> > wrote in message news:192240@a...
<news:192240@a...> ...
Thanks! One problem:
 
Compiler Error Message: BC30456: 'null' is not a member of 'SqlTypes'.
 
Code block is:
 
  for each dr in dsBoards.Tables("Forums").Rows
   for x = 0 to dsBoards.Tables("Forums").rows.count - 1
    if (dr(x)) = sqlTypes.null Then
     dr(x) = "None"
    end if
   next x
  next dr
 
any idea? I also tried for the sake of testing sqlTypes.dbNull; no go.

-----Original Message-----
From: Garland Frye [mailto:gfrye@s...]
Sent: Wednesday, July 10, 2002 9:36 AM
To: ASP+
Subject: [aspx] Re: Determing number of records in a table in a Datase t?


To work with your dataset you should do something like this
 
Dim dr As DataRow
Dim n As Integer
 
For each dr in DataSet.dt.rows
    For n = 0 to dt.rows.count - 1
        if dr(n) = DbType.DBNull.Value then        '******See footnote
            dr(n) = "Nothing"
    Next n
Next dr
 
 
******if using SQL Server, use SqlTypes.Null in the place of DBNull
 
Thanks,
Garland

--- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to  


Message #11 by Feduke Cntr Charles R <FedukeCR@m...> on Wed, 10 Jul 2002 13:19:58 -0400
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C22836.040337E0
Content-Type: text/plain;
	charset="iso-8859-1"

Okay, then try
 
If (dr(x) Is DbNull.Value)
{
}
 
    Although this makes no sense as Is has always come across to me as a
pointer comparison, but I guess maybe its a .Equals comparison.
 
- Chuck

-----Original Message-----
From: Oliver, Wells [mailto:WOliver@l...]
Sent: Wednesday, July 10, 2002 1:04 PM
To: ASP+
Subject: [aspx] Re: Determing number of records in a table in a Datase t?


Hmm:
 
Compiler Error Message: BC31080: Operator '=' is not defined for types
'System.Object' and 'System.DBNull'. Use 'Is' operator to compare two
reference types.

  for each dr in dsBoards.Tables("Forums").Rows
   for x = 0 to dsBoards.Tables("Forums").rows.count - 1
    if (dr(x) = dbNull.value) Then
     dr(x) = "None"
    end if
   next x
  next dr


-----Original Message-----
From: Garland Frye [mailto:gfrye@s...]
Sent: Wednesday, July 10, 2002 10:03 AM
To: ASP+
Subject: [aspx] Re: Determing number of records in a table in a Datase t?


My mistake, use DBNull.Value
 
Thanks,
Garland

"Lists, IT" < ITLists@l...
<mailto:ITLists@l...> > wrote in message news:192240@a...
<news:192240@a...> ...
Thanks! One problem:
 
Compiler Error Message: BC30456: 'null' is not a member of 'SqlTypes'.
 
Code block is:
 
  for each dr in dsBoards.Tables("Forums").Rows
   for x = 0 to dsBoards.Tables("Forums").rows.count - 1
    if (dr(x)) = sqlTypes.null Then
     dr(x) = "None"
    end if
   next x
  next dr
 
any idea? I also tried for the sake of testing sqlTypes.dbNull; no go.

-----Original Message-----
From: Garland Frye [mailto:gfrye@s...]
Sent: Wednesday, July 10, 2002 9:36 AM
To: ASP+
Subject: [aspx] Re: Determing number of records in a table in a Datase t?


To work with your dataset you should do something like this
 
Dim dr As DataRow
Dim n As Integer
 
For each dr in DataSet.dt.rows
    For n = 0 to dt.rows.count - 1
        if dr(n) = DbType.DBNull.Value then        '******See footnote
            dr(n) = "Nothing"
    Next n
Next dr
 
 
******if using SQL Server, use SqlTypes.Null in the place of DBNull
 
Thanks,
Garland

--- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to  

--- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to  


Message #12 by "Oliver, Wells" <WOliver@l...> on Wed, 10 Jul 2002 10:18:56 -0700
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C22835.DF82BC60
Content-Type: text/plain;
	charset="iso-8859-1"

Got it.
 
Although it doesn't seem to be saving my changes after this loop. Do I need
to do something to update the dataset _after_ the loop?

-----Original Message-----
From: Feduke Cntr Charles R [mailto:FedukeCR@m...]
Sent: Wednesday, July 10, 2002 10:20 AM
To: ASP+
Subject: [aspx] Re: Determing number of records in a table in a Datase t?


Okay, then try
 
If (dr(x) Is DbNull.Value)
{
}
 
    Although this makes no sense as Is has always come across to me as a
pointer comparison, but I guess maybe its a .Equals comparison.
 
- Chuck

-----Original Message-----
From: Oliver, Wells [mailto:WOliver@l...]
Sent: Wednesday, July 10, 2002 1:04 PM
To: ASP+
Subject: [aspx] Re: Determing number of records in a table in a Datase t?


Hmm:
 
Compiler Error Message: BC31080: Operator '=' is not defined for types
'System.Object' and 'System.DBNull'. Use 'Is' operator to compare two
reference types.

  for each dr in dsBoards.Tables("Forums").Rows
   for x = 0 to dsBoards.Tables("Forums").rows.count - 1
    if (dr(x) = dbNull.value) Then
     dr(x) = "None"
    end if
   next x
  next dr


-----Original Message-----
From: Garland Frye [mailto:gfrye@s...]
Sent: Wednesday, July 10, 2002 10:03 AM
To: ASP+
Subject: [aspx] Re: Determing number of records in a table in a Datase t?


My mistake, use DBNull.Value
 
Thanks,
Garland

"Lists, IT" < ITLists@l...
<mailto:ITLists@l...> > wrote in message news:192240@a...
<news:192240@a...> ...
Thanks! One problem:
 
Compiler Error Message: BC30456: 'null' is not a member of 'SqlTypes'.
 
Code block is:
 
  for each dr in dsBoards.Tables("Forums").Rows
   for x = 0 to dsBoards.Tables("Forums").rows.count - 1
    if (dr(x)) = sqlTypes.null Then
     dr(x) = "None"
    end if
   next x
  next dr
 
any idea? I also tried for the sake of testing sqlTypes.dbNull; no go.

-----Original Message-----
From: Garland Frye [mailto:gfrye@s...]
Sent: Wednesday, July 10, 2002 9:36 AM
To: ASP+
Subject: [aspx] Re: Determing number of records in a table in a Datase t?


To work with your dataset you should do something like this
 
Dim dr As DataRow
Dim n As Integer
 
For each dr in DataSet.dt.rows
    For n = 0 to dt.rows.count - 1
        if dr(n) = DbType.DBNull.Value then        '******See footnote
            dr(n) = "Nothing"
    Next n
Next dr
 
 
******if using SQL Server, use SqlTypes.Null in the place of DBNull
 
Thanks,
Garland

--- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to  

--- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to  

--- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to  


Message #13 by "Garland Frye" <gfrye@s...> on Wed, 10 Jul 2002 13:21:13 -0500
This is a multi-part message in MIME format.

------=_NextPart_000_001F_01C22814.A9C40CD0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Determing number of records in a table in a Dataset?It will not update 
the underlying database, until you call DataAdapter.Update(myDs)
where myDs =3D a dataset of your choice, but rest assured that the copy 
of the data contained in the dataset has been updated.

Thanks,
Garland
  "Oliver, Wells" <WOliver@l...> wrote in message 
news:192265@a...
  Got it.

  Although it doesn't seem to be saving my changes after this loop. Do I 
need to do something to update the dataset _after_ the loop?
    -----Original Message-----
    From: Feduke Cntr Charles R [mailto:FedukeCR@m...]
    Sent: Wednesday, July 10, 2002 10:20 AM
    To: ASP+
    Subject: [aspx] Re: Determing number of records in a table in a 
Datase t?


    Okay, then try

    If (dr(x) Is DbNull.Value)
    {
    }

        Although this makes no sense as Is has always come across to me 
as a pointer comparison, but I guess maybe its a .Equals comparison.

    - Chuck
      -----Original Message-----
      From: Oliver, Wells [mailto:WOliver@l...]
      Sent: Wednesday, July 10, 2002 1:04 PM
      To: ASP+
      Subject: [aspx] Re: Determing number of records in a table in a 
Datase t?


      Hmm:

      Compiler Error Message: BC31080: Operator '=3D' is not defined for 
types 'System.Object' and 'System.DBNull'. Use 'Is' operator to compare 
two reference types.

        for each dr in dsBoards.Tables("Forums").Rows
         for x =3D 0 to dsBoards.Tables("Forums").rows.count - 1
          if (dr(x) =3D dbNull.value) Then
           dr(x) =3D "None"
          end if
         next x
        next dr

        -----Original Message-----
        From: Garland Frye [mailto:gfrye@s...]
        Sent: Wednesday, July 10, 2002 10:03 AM
        To: ASP+
        Subject: [aspx] Re: Determing number of records in a table in a 
Datase t?


        My mistake, use DBNull.Value

        Thanks,
        Garland
          "Lists, IT" <ITLists@l...> wrote in message 
news:192240@a...
          Thanks! One problem:

          Compiler Error Message: BC30456: 'null' is not a member of 
'SqlTypes'.

          Code block is:

            for each dr in dsBoards.Tables("Forums").Rows
             for x =3D 0 to dsBoards.Tables("Forums").rows.count - 1
              if (dr(x)) =3D sqlTypes.null Then
               dr(x) =3D "None"
              end if
             next x
            next dr

          any idea? I also tried for the sake of testing 
sqlTypes.dbNull; no go.
            -----Original Message-----
            From: Garland Frye [mailto:gfrye@s...]
            Sent: Wednesday, July 10, 2002 9:36 AM
            To: ASP+
            Subject: [aspx] Re: Determing number of records in a table 
in a Datase t?


            To work with your dataset you should do something like this

            Dim dr As DataRow
            Dim n As Integer

            For each dr in DataSet.dt.rows
                For n =3D 0 to dt.rows.count - 1
                    if dr(n) =3D DbType.DBNull.Value then        
'******See footnote
                        dr(n) =3D "Nothing"
                Next n
            Next dr


            ******if using SQL Server, use SqlTypes.Null in the place of 
DBNull

            Thanks,
            Garland
        --- Change your mail options at http://p2p.wrox.com/manager.asp 
or 
      --- 
    --- 


Message #14 by "Subraya Hegde" <subrayah@i...> on Thu, 11 Jul 2002 10:39:17 +0530
Hi,

  I think U can write the code like this to find the total number of records
in
a table contained inside a DataSet:

ds.Tables[0].Rows.Count

-HegdeS


  Return to Index