Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: RE: Determing number of records in a table in a Datase


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

------=_NextPart_000_0014_01C2280C.A508C850
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Determing number of records in a table in a Dataset?There is a way to do it
with the dataset but because our applications have to run - without any code
changes - on Informix, Oracle and SQL Server we can not use it. (the problem
is Informix's drivers)

What we do instead is create a sql command and execute it - it's a minor
annoyance  anyway here is a copy of our "helper function"

Public Function Execute_Command(ByVal qry As String, ByVal BeginTrans As
Boolean, ByVal EndTrans As Boolean) As Boolean

Dim cmd As New OleDb.OleDbCommand()

Dim db As OleDb.OleDbConnection

Dim tr As OleDb.OleDbTransaction

db = Get_Database()

db.Open()

cmd = New OleDb.OleDbCommand()

cmd.Connection = db

'If BeginTrans Then

tr = db.BeginTransaction()

cmd.Transaction = tr

'End If



Execute_Command = True

Try

cmd.CommandType = CommandType.Text

cmd.CommandText = qry

cmd.ExecuteNonQuery()

'If EndTrans Then

tr.Commit()

'End If

Catch

tr.Rollback()

Execute_Command = False

End Try

cmd.Dispose()

db.Dispose()

End Function

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


  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

      --- 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 



  Return to Index