' PersonsMethod2 Example Imports System.Data.Oledb Public Class Form1 Inherits System.Windows.Forms.Form Private c As OleDbConnection Private da As OleDbDataAdapter Private ds As DataSet #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents txtName As System.Windows.Forms.TextBox Friend WithEvents txtGender As System.Windows.Forms.TextBox Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents txtAge As System.Windows.Forms.TextBox Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu Friend WithEvents mnuNext As System.Windows.Forms.MenuItem Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.txtName = New System.Windows.Forms.TextBox Me.txtGender = New System.Windows.Forms.TextBox Me.Label2 = New System.Windows.Forms.Label Me.txtAge = New System.Windows.Forms.TextBox Me.Label3 = New System.Windows.Forms.Label Me.MainMenu1 = New System.Windows.Forms.MainMenu Me.mnuNext = New System.Windows.Forms.MenuItem Me.SuspendLayout() ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(208, 32) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(64, 24) Me.Label1.TabIndex = 1 Me.Label1.Text = "Name" ' 'txtName ' Me.txtName.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtName.Location = New System.Drawing.Point(24, 32) Me.txtName.Name = "txtName" Me.txtName.Size = New System.Drawing.Size(168, 29) Me.txtName.TabIndex = 0 Me.txtName.Text = "" ' 'txtGender ' Me.txtGender.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtGender.Location = New System.Drawing.Point(24, 80) Me.txtGender.Name = "txtGender" Me.txtGender.Size = New System.Drawing.Size(168, 29) Me.txtGender.TabIndex = 2 Me.txtGender.Text = "" ' 'Label2 ' Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Location = New System.Drawing.Point(208, 80) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(80, 24) Me.Label2.TabIndex = 3 Me.Label2.Text = "Gender" ' 'txtAge ' Me.txtAge.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtAge.Location = New System.Drawing.Point(24, 128) Me.txtAge.Name = "txtAge" Me.txtAge.Size = New System.Drawing.Size(168, 29) Me.txtAge.TabIndex = 4 Me.txtAge.Text = "" ' 'Label3 ' Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label3.Location = New System.Drawing.Point(208, 128) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(80, 24) Me.Label3.TabIndex = 5 Me.Label3.Text = "Age" ' 'MainMenu1 ' Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuNext}) ' 'mnuNext ' Me.mnuNext.Index = 0 Me.mnuNext.Text = "Next Row" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(312, 190) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.txtAge) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.txtGender) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.txtName) Me.Menu = Me.MainMenu1 Me.Name = "Form1" Me.Text = "PersonsMethod2 Example" Me.ResumeLayout(False) End Sub #End Region Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load c = New OleDbConnection c.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=c:\persons.mdb" c.Open() Dim s As OleDbCommand s = c.CreateCommand() s.CommandType = CommandType.Text s.CommandText = "SELECT * FROM PersonData" Dim da As New OleDbDataAdapter da.SelectCommand = s ds = New DataSet da.Fill(ds, "PersonData") txtName.DataBindings.Add( _ New Binding("Text", ds, "PersonData.Name")) txtGender.DataBindings.Add( _ New Binding("Text", ds, "PersonData.Gender")) txtAge.DataBindings.Add( _ New Binding("Text", ds, "PersonData.Age")) End Sub Private Sub mnuNext_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles mnuNext.Click Me.BindingContext(ds, "PersonData").Position += 1 End Sub End Class