VB 2003. This is what I wrote and it does not work;
Imports System.Data.OleDb
Public Class Form2
Inherits System.Windows.Forms.Form
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
'WINDOWS GENERATED
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
OleDbDataAdapter1.Fill(DataSet11)
End Sub
Private Sub exitbutton_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles exitbutton.Click
Me.Close()
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:\Documents and Settings\Name\Desktop\FillMe.mdb;")
'provider to be used when working with access database
cn.Open()
cmd = New OleDbCommand("select * from MainTable", cn)
dr = cmd.ExecuteReader
While dr.Read()
TextBox1.Text = dr(0)
TextBox2.Text = dr(1)
TextBox3.Text = dr(2)
'loading data into TextBoxes by column index
End While
Catch
End Try
dr.Close()
cn.Close()
End Sub
End Class
John said:
How do I input and retrieve data from tables in an .mdb file? I use vb.net
I have a book by the way, and it only tells me how to create a data grid,
and display single records.