Read Access Data table and store data in ListBox : Database ListBox « Database ADO.net « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Date Time
8.Development
9.Event
10.File Directory
11.Generics
12.GUI
13.Internationalization I18N
14.Language Basics
15.LINQ
16.Network Remote
17.Reflection
18.Security
19.Thread
20.Windows Presentation Foundation
21.Windows System
22.XML
23.XML LINQ
VB.Net » Database ADO.net » Database ListBoxScreenshots 
Read Access Data table and store data in ListBox
Read Access Data table and store data in ListBox

 Imports System
 Imports System.Drawing
 Imports System.Collections
 Imports System.ComponentModel
 Imports System.Windows.Forms
 Imports System.Data
 Imports System.Data.OleDb

 
Public Class MainClass

    Shared Sub Main(  )
        Application.Run(New ADOForm1() )
    End Sub

   
End Class

  Public Class ADOForm1
     Inherits System.Windows.Forms.Form

     Private components As System.ComponentModel.Container
     Private lbEmployees As System.Windows.Forms.ListBox

     Public Sub New(  )
         InitializeComponent(  )

         Dim connectionString As String = _
             "provider=Microsoft.JET.OLEDB.4.0; " & _
              "data source = Employee.mdb"

         Dim commandString As String = _
           "Select FirstName, LastName from Employee"

         Dim myDataAdapter As New OleDbDataAdapter_
           commandString, connectionString)

         Dim myDataSet As New DataSet(  )

         myDataAdapter.Fill(myDataSet, "Employee")

         Dim myDataTable As DataTable = myDataSet.Tables(0)

         Dim tempRow As DataRow
         For Each tempRow In myDataTable.Rows
             lbEmployees.Items.Add((tempRow("FirstName"& _
               " (" & tempRow("LastName"")"))
         Next

     End Sub 'New

     Private Sub InitializeComponent(  )
         Me.components = New System.ComponentModel.Container(  )
         Me.lbEmployees = New System.Windows.Forms.ListBox(  )
         lbEmployees.Location = New System.Drawing.Point(4824)
         lbEmployees.Size = New System.Drawing.Size(368160)
         lbEmployees.TabIndex = 0
         Me.Text = "ADOFrm1"
         Me.AutoScaleBaseSize = New System.Drawing.Size(513)
         Me.ClientSize = New System.Drawing.Size(464273)
         Me.Controls.Add(lbEmployees)
     End Sub 

 End Class 
           
       
Employee.zip( 7 k)
Related examples in the same category
1.Store Database data into a ListBoxStore Database data into a ListBox
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.