bopo
Member
- Joined
- Dec 10, 2006
- Messages
- 13
- Programming Experience
- Beginner
HI
Below is the coding, I have finally been able to extra data from a MS Acess database and make it display in text boxes, however I tried switching to list boxes and it totally doesnt work, below the code:
Below is the coding, I have finally been able to extra data from a MS Acess database and make it display in text boxes, however I tried switching to list boxes and it totally doesnt work, below the code:
VB.NET:
Imports System.Data.OleDb
Public Class ProblemForm
Inherits System.Windows.Forms.Form
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Private Sub ProblemForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Emp.mdb;")
cn.Open()
cmd = New OleDbCommand("select * from table1", cn)
dr = cmd.ExecuteReader
While dr.Read
lstproblemd.Text = dr(1) 'so how do I tell a list box to do this?
lsturgency.Text = dr(2)
'loading data
End While
Catch
End Try
dr.Close()
cn.Close()
End Sub
End Class
Last edited by a moderator: