السلام عليكم ورحمة الله
ردي السابق لأني فهمت أن هذيك رغبتك، آسف. واسمك حاول أجيبه بالعربي ما لقيت أي اسم يركب على الحروف raoe تعبني
شوف هذا الكود اسم الاجراءين ComboBoxFill وLogin من مشروع أحد الأخوة الله يذكره بالخير،
وحطيت لك أسطر الاستخدام معاه عشان تعرف الطريقة
الاجراء ComboBoxFill لتعبئة أي كمبوبكس بس أرسل له اسم الكمبوبكس والكونكشن واسم الجدول واسم الحقل الأساسي والحقل الثاني اختياري
PHP كود :
Dim conn As New OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0; Data Source = Database1.accdb;")
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
ComboBoxFill(Me.ComboBox1, conn, "Users", "Username", "ID")
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If Login(Me.ComboBox1.Text, Me.TextBox1.Text) Then
MsgBox("مرحباً بك")
Else
MsgBox("عفواً... إسم المستخدم أو كلمة المرور غير صحيحة")
Me.TextBox1.Clear()
Me.TextBox1.Focus()
End If
End Sub
Public Sub ComboBoxFill(comboBox As ComboBox, connection As OleDbConnection, table As String, display As String, Optional value As String = "")
Try
Using da As New OleDbDataAdapter(" SELECT * FROM [" & table & "] ", connection)
Dim dt As New DataTable
da.Fill(dt)
comboBox.DataSource = dt
comboBox.DisplayMember = display
comboBox.ValueMember = value
End Using
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Public Function Login(username As String, password As String) As Boolean
Try
Using da As New OleDbDataAdapter("SELECT * FROM [Users] WHERE [Username] = @Username AND [Password] = @Password ", conn)
da.SelectCommand.Parameters.AddWithValue("@Username", username)
da.SelectCommand.Parameters.AddWithValue("@Password", password)
Using myDatatable As New DataTable
If da.Fill(myDatatable) > 0 Then Return True
End Using
End Using
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function

