الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

شرح أكواد

بدأه نوشه المنكوشه في 21 مايو 2010 · 1 رد · 775 مشاهدة · في قواعد بيانات Microsoft Access
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

عندي بعض الأكواد لربط قاعدة البيانات بالفيجوال بيسك

والمشكله اني مو فاهمه هالأكواد ابغى اذا ممكن شرح وافي لأن مناقشتي تتطلب شرح كل نقطه بالكود

وببدا بعرض الأكواد

1)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim myDV As New DataView(ds.Tables(0))

myDV.RowFilter = ("Employee name='" + TextBox1.Text + "'")

myDV.Sort = "Employee name"

End Sub

2)

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click

If con.State = ConnectionState.Open Then

ds.Tables("database of stafffill").Rows(x).Item(0) = TextBox2.Text

ds.Tables("database of stafffill").Rows(x).Item(0) = TextBox3.Text

ds.Tables("database of stafffill").Rows(x).Item(0) = TextBox4.Text

ds.Tables("database of stafffill").Rows(x).Item(0) = TextBox5.Text

ds.Tables("database of stafffill").Rows(x).Item(0) = TextBox6.Text

ds.Tables("database of stafffill").Rows(x).Item(0) = TextBox7.Text

' builds sql for me

Dim cb As New OleDb.OleDbCommandBuilder(da)

da.Update(ds, "database of stafffill")

Else

MsgBox("connection not open")

End If

End Sub

3)

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim cb As New OleDb.OleDbCommandBuilder(da)

ds.Tables("database of stafffill").Rows(x).Delete()

da.Update(ds, "database of stafffill")

maxrows -= 1

x = 0

End Sub

4)

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

'first add a new row then comit the new row to the database

If con.State = ConnectionState.Open Then

x = maxrows

Dim cd As New OleDb.OleDbCommandBuilder(da)

Dim dr As DataRow ' assign data row

' create the new empty row for table instructors

dr = ds.Tables("database of stafffill").NewRow

dr.Item(0) = maxrows + 1 'not good idea :repeated ids could exist

dr.Item(1) = TextBox2.Text

dr.Item(1) = TextBox3.Text

'add the new row to the dataset

ds.Tables("database of stafffill").Rows.Add(dr)

' update dataadaptor

Dim flag As Integer = da.Update(ds, "database of stafffill")

If flag > 0 Then

MsgBox("record added.")

maxrows += 1

x = 0 ' return to first record

Labelflag.Text = "record no. " & x + 1 & " of " & maxrows

End If ' f:ag

End If ' con.state

End Sub

5)

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

x = 0

Displayrecord()

End Sub

6)

Private Sub Button7_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

If x <> maxrows - 1 Then x += 1

Displayrecord()

End Sub

7)

Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

If x <> 0 Then x -= 1

Displayrecord()

End Sub

8)

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button8.Click

x = maxrows - 1

Displayrecord()

End Sub

وهذا الكود حق الربط بين قواعد البيانات والفيجوال

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click

con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =database of staff4.mdb"

If File.Exists("database of staff4.mdb") Then

con.Open()

If con.State = ConnectionState.Open Then

MsgBox("database of staff4file")

sql = "select * from database of staff4file"

da = New OleDb.OleDbDataAdapter(sql, con)

da.Fill(ds, "database of staff4fill")

maxrows = ds.Tables("database of staff4fill").Rows.Count

If maxrows > 0 Then

x = 0

Displayrecord()

End If

Else

MsgBox("Connection Error")

End If 'Con.State

Else

MsgBox("File Not found")

End If 'File.Exis

End Sub

أحب اوضح انو أنا عارفه كل شيفره وش تسوي بس المشكله انو بالمناقشه رح يسألوني عن الكلام اللي بالشيفره وش تعني

وهذا اللي أنا خايفه منه

وبس

الله يجزاكم خير ساعدوني حتى لو الموضوع مكانه مو هنا بس بجد محتاجه مساعدتكم بليز

#2

وينكم بليز

مواضيع مشابهة