Results 1 to 7 of 7

Thread: ado.net datasets

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2000
    Posts
    53

    ado.net datasets

    How does one scroll through a dataset in ado.net In ado it was simple the whole do while loop and movenext thing but how about with datasets

  2. #2
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    like so

    Code:
    Option Explicit On
    Option Strict On
    
    Imports System
    Imports System.Data
    Imports System.Data.OleDb
    Imports Microsoft.VisualBasic
    
    Public Class dbConsole
    	
    	Public Shared Sub Main()
    		Dim db As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & AppPath & "dbConsole\db.mdb;")
    		Dim cmd As OleDbCommand = db.CreateCommand()
    
    		cmd.CommandText = "Select * From People Order By People.Name Asc;"
    
    		db.Open
    		
    		Dim r As OleDbDataReader = cmd.ExecuteReader()
    		
    		Console.WriteLine()
    
    		Do While r.Read()
    			Console.WriteLine(vbTab & "Name: " & r.GetString(0))
    			Console.WriteLine(vbTab & "Age: " & r.GetString(1))
    			Console.WriteLine(vbTab & "Sex: " & r.GetString(2))
    			Console.WriteLine()
    		Loop
    	End Sub
    
    	Private Function AppPath() As String
    		AppPath = Mid$(Application.ExecutablePath, 1, InStrRev(Application.ExecutablePath, "\"))
    	End Function
    
    End Class
    Attached Files Attached Files
    Magiaus

    If I helped give me some points.

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2000
    Posts
    53
    thanks for the explanation so you dont have to move it to the next record in the data reader? It does it automatically in the datareader when your looping

  4. #4
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    nope

    0_0
    Magiaus

    If I helped give me some points.

  5. #5
    Lively Member
    Join Date
    Feb 2002
    Posts
    67

    Class Inheritance

    Hi People,

    Having some problems using inheritance in vb.net. Maybe you can help. Im trying to use the base class (oleDbConn) within another class. The error im getting states i can't use more than one class? do i need to use module? how do u use classes.

    Thanks In Advance

    'Base Class

    Imports System
    Imports System.Data
    Imports System.Data.OleDb
    Imports Microsoft.VisualBasic

    Public Class oleDbConn
    Public Shared Sub Main()


    Dim dbase As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\helpdesk.mdb;")
    Dim faultsDAdapter As New OleDbDataAdapter("Select * from faults", dbase)
    Dim faultsDSet As DataSet = New DataSet()

    End Sub
    End Class

    'class im getting errors from.

    Public Class administration
    Inherits System.Windows.Forms.Form

    Inherits class2

  6. #6
    Lively Member ac11965's Avatar
    Join Date
    May 2000
    Location
    East London, South Africa
    Posts
    69
    hi,

    how about moving back one record?

  7. #7
    Junior Member
    Join Date
    Dec 2001
    Posts
    18
    .Net only allows you to inherit only one class

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width