Kullanıcımı Adminmi anlarsınız mesajla ve gereki kodları ona göre yazarsınız.
Sub Label2_Click()
Dim baglan As Object, rs As Object
Dim yetki As String, varmi As Boolean
Set baglan = CreateObject("adodb.connection")
Set rs = CreateObject("adodb.recordset")
varmi = False
baglan.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ThisWorkbook.Path & "\Database.accdb;Persist Security Info=False;"
If baglan.State <> adStateClosed Then
baglan.Close
Exit Sub
End If
baglan.Open
'--------------------------------------------------------------------------------------------------------------------------------------------------------
rs.Open "select * from [Users] where User_Name ='" & TextBox1.Value & "' and Password ='" & TextBox2.Value & "' and Role ='admin'", baglan, 1, 1
If rs.RecordCount > 0 Then
yetki = "Admin"
varmi = True
GoTo 1
End If
'--------------------------------------------------------------------------------------------------------------------------------------------------------
rs.Close
rs.Open "select * from [Users] where User_Name ='" & TextBox1.Value & "' and Password ='" & TextBox2.Value & "' and Role ='user'", baglan, 1, 1
If rs.RecordCount > 0 Then
yetki = "Kullanici"
varmi = True
End If
'--------------------------------------------------------------------------------------------------------------------------------------------------------
1
If varmi = True Then
MsgBox "Basarili ve " & yetki & " olarak acilacak", vbInformation
Else
MsgBox "sifre yada kullanici adi yanlis", vbCritical
End If
rs.Close
baglan.Close
Set rs = Nothing
Set baglan = Nothing
End Sub