' جملة الربط
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Code.accdb")
Dim da As New OleDbDataAdapter ' جدول مصدر المعلومات
Dim dt As New DataTable ' مكان التخزين
Sub Load_Data()
dt.Clear()
da = New OleDbDataAdapter("Select * From Table1", con)
da.Fill(dt)
End Sub
Sub save_Data()
Dim save As New OleDbCommandBuilder(da)
save.QuotePrefix = "["
save.QuoteSuffix = "]"
da.Update(dt)
dt.AcceptChanges()
End Sub
' جملة تحميل الجدول الي الداتا جريد فيو
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Load_Data()
DataGridView1.DataSource = dt
End Sub
' كود الحذف
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
dt.Rows(BindingContext(dt).Position).Delete()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
save_Data()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
Try
Dim names As New List(Of String)
For Each i In RichTextBox1.Lines
names.Add("'" & i & "'")
Next
Dim sql As String = "Select * From [Table1] WHERE [Name] IN (" & String.Join(",", names) & ") "
dt.Clear()
da = New OleDbDataAdapter(sql, con)
da.Fill(dt)
Catch ex As Exception
End Try
End Sub
Private Sub RichTextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox2.TextChanged
Try
Dim salary As New List(Of String)
For Each i In RichTextBox2.Lines
salary.Add(i)
Next
Dim sql As String = "Select * From [Table1] WHERE [salary] IN (" & String.Join(",", salary) & ") "
dt.Clear()
da = New OleDbDataAdapter(sql, con)
da.Fill(dt)
Catch ex As Exception
End Try
End Sub
End Class
1- عند مسح الاسم الموجود يبقي حرف واحد ثم يغلق البرنامج
2- لايقبل كتابة اسم اخر الا الاسم الاول فقط ولا ينتقل الي السطر الثاني بعد الضغط علي Inter
حتي اتمكن من كتابة سطر اخر