10-09-21, 02:03 AM
(10-09-21, 02:00 AM)waw كتب : رجاء لا تضع صور للكود بل ضع الكود نفسه بالنسخ واللصق
كود كلاس الاتصال كامل
وكود الفورم كامل
اسف هذا كود الفورم
Imports MySql.Data.MySqlClient
Imports MySql.Data.MySqlClient.MySqlException
Public Class Login_Form
Private Sub ButOK_Click(sender As Object, e As EventArgs) Handles ButOK.Click
Dim conn As New MY_CONNECTON()
Dim adb As New MySqlDataAdapter()
Dim tb As New DataTable()
Dim command As New MySqlCommand(" SELECT `UserID`, `Password` FROM `users` WHERE `UserID` = @UserID AND `Password` = @Passowrd ", conn.getConnection())
command.Parameters.Add("@usid", MySqlDbType.VarChar).Value = TextID.Text
command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = TextPass.Text
adb.SelectCommand = command
adb.Fill(tb)
If tb.Rows.Count > 0 Then
MsgBox(" LOGGED ")
Else
MsgBox(" NOT LOGGED ")
End If
End Sub
Private Sub ButCancel_Click(sender As Object, e As EventArgs) Handles ButCancel.Click
Application.Exit()
End Sub
End Class
وهذا كود الكلاس
Imports MySql.Data.MySqlClient
Public Class MY_CONNECTON
Private connection As New MySqlConnection(" server =localhost; User=root; Password=; Database=caffe12; Port=3306; ")
ReadOnly Property getConnection() As MySqlConnection
Get
Return connection
End Get
End Property
Sub openConnection()
If connection.State = ConnectionState.Closed Then
connection.Open()
End If
End Sub
Sub closeConnection()
If connection.State = ConnectionState.Open Then
connection.Close()
End If
End Sub
End Class
