Sub ConnectToSQL()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
' تكوين اتصال ODBC
Set conn = New ADODB.Connection
conn.Open "DSN=MySQLServer;UID=myusername;PWD=mypassword"
' تنفيذ استعلام SQL
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM Customers", conn
' عرض النتائج في نموذج (على سبيل المثال)
Do While Not rs.EOF
Me.txtCustomerID.Value = rs!CustomerID
Me.txtCustomerName.Value = rs!CustomerName
rs.MoveNext
Loop
' إغلاق الاتصال والسجل
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
End Sub