form3-View records

Imports System.data.oledb
Public Class Form3
Inherits System.Windows.Forms.Form
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Dim f2 As Form2
Dim i, j, k, l As Integer
Dim a, b, c As String

#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 Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents Label8 As System.Windows.Forms.Label
Friend WithEvents Label9 As System.Windows.Forms.Label
Friend WithEvents Label10 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Button4 As System.Windows.Forms.Button
Friend WithEvents Label11 As System.Windows.Forms.Label
Friend WithEvents Label12 As System.Windows.Forms.Label
Friend WithEvents Label13 As System.Windows.Forms.Label
Friend WithEvents Label14 As System.Windows.Forms.Label
Friend WithEvents Label15 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.Label5 = New System.Windows.Forms.Label
Me.Label6 = New System.Windows.Forms.Label
Me.Label7 = New System.Windows.Forms.Label
Me.Label8 = New System.Windows.Forms.Label
Me.Label9 = New System.Windows.Forms.Label
Me.Label10 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Button3 = New System.Windows.Forms.Button
Me.Button4 = New System.Windows.Forms.Button
Me.Label11 = New System.Windows.Forms.Label
Me.Label12 = New System.Windows.Forms.Label
Me.Label13 = New System.Windows.Forms.Label
Me.Label14 = New System.Windows.Forms.Label
Me.Label15 = New System.Windows.Forms.Label
Me.SuspendLayout()

‘Label1

Me.Label1.Font = New System.Drawing.Font(“Microsoft Sans Serif”, 21.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(128, 8)
Me.Label1.Name = “Label1”
Me.Label1.Size = New System.Drawing.Size(200, 40)
Me.Label1.TabIndex = 3
Me.Label1.Text = “Assignment 4”

‘Label2

Me.Label2.Font = New System.Drawing.Font(“Microsoft Sans Serif”, 9.75!, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(8, 56)
Me.Label2.Name = “Label2”
Me.Label2.Size = New System.Drawing.Size(112, 24)
Me.Label2.TabIndex = 4
Me.Label2.Text = “View Records”

‘Label3

Me.Label3.Font = New System.Drawing.Font(“Microsoft Sans Serif”, 8.0!)
Me.Label3.Location = New System.Drawing.Point(40, 120)
Me.Label3.Name = “Label3”
Me.Label3.Size = New System.Drawing.Size(80, 24)
Me.Label3.TabIndex = 5
Me.Label3.Text = “Name”

‘Label4

Me.Label4.Font = New System.Drawing.Font(“Microsoft Sans Serif”, 8.0!)
Me.Label4.Location = New System.Drawing.Point(40, 144)
Me.Label4.Name = “Label4”
Me.Label4.Size = New System.Drawing.Size(80, 24)
Me.Label4.TabIndex = 6
Me.Label4.Text = “Username”

‘Label5

Me.Label5.Font = New System.Drawing.Font(“Microsoft Sans Serif”, 8.0!)
Me.Label5.Location = New System.Drawing.Point(40, 168)
Me.Label5.Name = “Label5”
Me.Label5.Size = New System.Drawing.Size(80, 24)
Me.Label5.TabIndex = 7
Me.Label5.Text = “Roll no:”

‘Label6

Me.Label6.Font = New System.Drawing.Font(“Microsoft Sans Serif”, 8.0!)
Me.Label6.Location = New System.Drawing.Point(40, 192)
Me.Label6.Name = “Label6”
Me.Label6.Size = New System.Drawing.Size(80, 24)
Me.Label6.TabIndex = 8
Me.Label6.Text = “Age”

‘Label7

Me.Label7.Location = New System.Drawing.Point(120, 120)
Me.Label7.Name = “Label7”
Me.Label7.Size = New System.Drawing.Size(152, 23)
Me.Label7.TabIndex = 9

‘Label8

Me.Label8.Location = New System.Drawing.Point(120, 144)
Me.Label8.Name = “Label8”
Me.Label8.Size = New System.Drawing.Size(152, 23)
Me.Label8.TabIndex = 10

‘Label9

Me.Label9.Location = New System.Drawing.Point(120, 168)
Me.Label9.Name = “Label9”
Me.Label9.Size = New System.Drawing.Size(152, 23)
Me.Label9.TabIndex = 11

‘Label10

Me.Label10.Location = New System.Drawing.Point(120, 192)
Me.Label10.Name = “Label10”
Me.Label10.Size = New System.Drawing.Size(152, 23)
Me.Label10.TabIndex = 12

‘Button1

Me.Button1.Cursor = System.Windows.Forms.Cursors.Hand
Me.Button1.Location = New System.Drawing.Point(208, 248)
Me.Button1.Name = “Button1”
Me.Button1.Size = New System.Drawing.Size(64, 32)
Me.Button1.TabIndex = 13
Me.Button1.Text = “Next”

‘Button2

Me.Button2.Cursor = System.Windows.Forms.Cursors.Hand
Me.Button2.Location = New System.Drawing.Point(144, 248)
Me.Button2.Name = “Button2”
Me.Button2.Size = New System.Drawing.Size(64, 32)
Me.Button2.TabIndex = 14
Me.Button2.Text = “Prev”

‘Button3

Me.Button3.Cursor = System.Windows.Forms.Cursors.Hand
Me.Button3.Location = New System.Drawing.Point(312, 248)
Me.Button3.Name = “Button3”
Me.Button3.Size = New System.Drawing.Size(64, 32)
Me.Button3.TabIndex = 15
Me.Button3.Text = “Last”

‘Button4

Me.Button4.Cursor = System.Windows.Forms.Cursors.Hand
Me.Button4.Location = New System.Drawing.Point(48, 248)
Me.Button4.Name = “Button4”
Me.Button4.Size = New System.Drawing.Size(64, 32)
Me.Button4.TabIndex = 16
Me.Button4.Text = “First”

‘Label11

Me.Label11.Location = New System.Drawing.Point(256, 96)
Me.Label11.Name = “Label11”
Me.Label11.TabIndex = 17
Me.Label11.Text = “Record no:”

‘Label12

Me.Label12.Location = New System.Drawing.Point(352, 96)
Me.Label12.Name = “Label12”
Me.Label12.Size = New System.Drawing.Size(56, 23)
Me.Label12.TabIndex = 18

‘Label13

Me.Label13.Location = New System.Drawing.Point(352, 64)
Me.Label13.Name = “Label13”
Me.Label13.Size = New System.Drawing.Size(56, 23)
Me.Label13.TabIndex = 20

‘Label14

Me.Label14.Location = New System.Drawing.Point(256, 64)
Me.Label14.Name = “Label14”
Me.Label14.TabIndex = 19
Me.Label14.Text = “Total records”

‘Label15

Me.Label15.Location = New System.Drawing.Point(8, 16)
Me.Label15.Name = “Label15”
Me.Label15.TabIndex = 21

‘Form3

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(424, 326)
Me.Controls.Add(Me.Label15)
Me.Controls.Add(Me.Label13)
Me.Controls.Add(Me.Label14)
Me.Controls.Add(Me.Label12)
Me.Controls.Add(Me.Label11)
Me.Controls.Add(Me.Button4)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label10)
Me.Controls.Add(Me.Label9)
Me.Controls.Add(Me.Label8)
Me.Controls.Add(Me.Label7)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = “Form3”
Me.Text = “Form3”
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

End Sub

Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cn = New OleDbConnection(“provider=microsoft.jet.oledb.4.0;data source=c:\a4.mdb”)
cn.Open()
cmd = New OleDbCommand(“select * from table1”, cn)
dr = cmd.ExecuteReader
While dr.Read()
l += 1
End While
dr.Close()
cn.Close()
Label13.Text = l

cn = New OleDbConnection(“provider=microsoft.jet.oledb.4.0;data source=c:\a4.mdb”)
cn.Open()
cmd = New OleDbCommand(“select * from table1”, cn)
dr = cmd.ExecuteReader

While dr.Read()
j += 1
Label7.Text = dr(3)
Label8.Text = dr(0)
Label9.Text = dr(2)
Label10.Text = dr(4)
Label12.Text = j
Exit While

End While
dr.Close()
cn.Close()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
k = 0
If j < l Then

j += 1
‘once again
cn = New OleDbConnection(“provider=microsoft.jet.oledb.4.0;data source=c:\a4.mdb”)
cn.Open()
cmd = New OleDbCommand(“select * from table1”, cn)
dr = cmd.ExecuteReader
While dr.Read()
k += 1
If k = j Then
Label7.Text = dr(3)
Label8.Text = dr(0)
Label9.Text = dr(2)
Label10.Text = dr(4)
Label12.Text = j
Exit While
End If

End While

dr.Close()
cn.Close()

ElseIf j = l Then
cn = New OleDbConnection(“provider=microsoft.jet.oledb.4.0;data source=c:\a4.mdb”)
cn.Open()
cmd = New OleDbCommand(“select * from table1”, cn)
dr = cmd.ExecuteReader
MsgBox(“lastrecord”)
dr.Read()
j = 1
Label7.Text = dr(3)
Label8.Text = dr(0)
Label9.Text = dr(2)
Label10.Text = dr(4)
Label12.Text = j

End If
End Sub

Private Sub Label13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label13.Click

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
k = 0
j -= 1
If j > 0 Then
‘once again
cn = New OleDbConnection(“provider=microsoft.jet.oledb.4.0;data source=c:\a4.mdb”)
cn.Open()
cmd = New OleDbCommand(“select * from table1”, cn)
dr = cmd.ExecuteReader
While dr.Read()
k += 1
If k = j Then
Label7.Text = dr(3)
Label8.Text = dr(0)
Label9.Text = dr(2)
Label10.Text = dr(4)
Label12.Text = j
Exit While
End If

End While

dr.Close()
cn.Close()

ElseIf j = 0 Then
cn = New OleDbConnection(“provider=microsoft.jet.oledb.4.0;data source=c:\a4.mdb”)
cn.Open()
cmd = New OleDbCommand(“select * from table1”, cn)
dr = cmd.ExecuteReader
MsgBox(“First record”)
j = l
While dr.Read()
Label7.Text = dr(3)
Label8.Text = dr(0)
Label9.Text = dr(2)
Label10.Text = dr(4)
Label12.Text = j

End While
dr.Close()
cn.Close()
End If
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
j = 1
cn = New OleDbConnection(“provider=microsoft.jet.oledb.4.0;data source=c:\a4.mdb”)
cn.Open()
cmd = New OleDbCommand(“select * from table1”, cn)
dr = cmd.ExecuteReader
dr.Read()
Label7.Text = dr(3)
Label8.Text = dr(0)
Label9.Text = dr(2)
Label10.Text = dr(4)
Label12.Text = j
dr.Close()
cn.Close()

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
j = l
cn = New OleDbConnection(“provider=microsoft.jet.oledb.4.0;data source=c:\a4.mdb”)
cn.Open()
cmd = New OleDbCommand(“select * from table1”, cn)
dr = cmd.ExecuteReader
While dr.Read()
Label7.Text = dr(3)
Label8.Text = dr(0)
Label9.Text = dr(2)
Label10.Text = dr(4)
Label12.Text = j
End While
dr.Close()
cn.Close()
End Sub
End Class

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s