' عايزين نعرف الاتصال بقاعدة البيانات
Imports System.Data
Imports System.Data.OleDb
Public Class Form2
'عايز نربط بقى بقاعدة بيانات أكسيس
Dim connection As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\Users\gamal\Pictures\aa.mdb")
'عايزين نعرف مسار قاعدة البيانات
Dim index As Integer
Dim table As New DataTable
Public Sub loaddata(ByVal position As Integer)
Dim command As New OleDbCommand("select*from table1", connection)
Dim adapter As New OleDbDataAdapter(command)
adapter.Fill(table)
TextBox1.Text = table.Rows(position)(0).ToString()
TextBox2.Text = table.Rows(position)(1).ToString()
TextBox3.Text = table.Rows(position)(2).ToString()
TextBox5.Text = table.Rows(position)(3).ToString()
TextBox4.Text = table.Rows(position)(4).ToString()
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
loaddata(index)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'لعرض أول سجل في قاعدة البيانات
index = 0
loaddata(index)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
index += 1
loaddata(index)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
index -= 1
loaddata(index)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
index = table.Rows.Count() - 1
loaddata(index)
End Sub
End Class
No comments:
Post a Comment