هذا كود الدخول للمستخدم ارجو اذا كان فيه ملاحظات او فكرة لاختصار الكود الا يبخل بها علينا :
كتب في البرناج عند فتحة : رقم المستخدم = احمد رقم المرور = 1401406
Imports System.Data.Common
Imports System.Data.OleDb
Imports System.Data
Public Class Form1
Dim mycon As New OleDbConnection
Dim mycmd As OleDbCommand
Dim myreader As OleDbDataReader
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtpassword.PasswordChar = "*"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sqlstr As String
Try
If txtname.Text = "" Or txtpassword.Text = "" Then
MsgBox("تأكد من إسم المستخدم وقم المرور ")
Exit Sub
End If
'================================================
'set provider string for open connect data suors
mycon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|vbtest.mdb"
'opne data base and connection
mycon.Open()
'================================================
'sql string to select user name and password to open form 2
sqlstr = "select user_name , user_password from user_info where user_name=? and user_password =? "
'set oledbcommad to open and run cmd
Dim mycmd As New OleDbCommand(sqlstr, mycon)
'set parameters to send name and password
mycmd.Parameters.AddWithValue("?", txtname.Text)
mycmd.Parameters.AddWithValue("?", txtpassword.Text)
'================================================
'reading a retern value from data by parameter
myreader = mycmd.ExecuteReader()
myreader.Read()
'================================================
'if myreader object is read data then open form2 and close datareader & connection
If myreader.HasRows Then
myreader.Close()
mycon.Close()
Form2.Show()
Me.Hide()
Else
myreader.Close()
mycon.Close()
MsgBox("تأكد من إسم المستخدم ورقم المرور")
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Dispose()
End Sub
End Classارجو ان يكون واضح وتحياتي لكم بالتوفيق .