Click here to Skip to main content
16,004,727 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm developing a system in vbnet and access. I would like that my system gives access to 2 user with different levels of access, I would like that the first one as admin that access it own form called LibrarySystemForm as an administrator and the second one a User that access its own form too called cuulibForm.
Here the code I've used give them the to the same access, what should I do, to have another access to the second user that is different to the admin? ok I hope to get your advice
I would suggest someone who may advice me how I can change a bit on this following codes.

VB
Imports System.Data.OleDb

Public Class LoginCuuLibForm
    Dim con As New OleDbConnection

    Private Sub LoginCuuLibForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        con.ConnectionString = "Provider= Microsoft.ACE.OLEDB.12.0;Data Source = CUULibDB.mdb.accdb; persist security info =false"
    End Sub

    Public Function ask()
        Dim dt As New DataTable
        Dim ds As New DataSet
        ds.Tables.Add(dt)
        con.Open()
        Dim da As New OleDbDataAdapter("Select * from login", con)
        da.Fill(dt)

        For Each datarow In dt.Rows

            If txtUsername.Text = datarow.item(1) And txtPassword.Text = datarow(2) And cobSertype.Text = datarow(3) Then
                con.Close()
                Return True


            End If

        Next
        con.Close()
        Return False

    End Function


    Private Sub btnLog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLog.Click
        If ask() = True Then
            LibrarySystemForm.Show()
        Else
            MessageBox.Show("invalid")
        End If

       
    End Sub



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        txtUsername.Clear()
        txtPassword.Clear()
    End Sub
End Class
Posted
Comments
ZurdoDev 30-Jul-13 12:47pm    
What exactly is your question?
DAVID DUSHIMIMANA 30-Jul-13 13:05pm    
My question is about how I can have two different accessibility to users, one administrator and others, as you see here in codes above, the datarow is scaning the the each row and after muching with record it display the LibrarySystemForm.
I would like to store in my database two users only, the first one admin and second user, and those two users should have two different form, so I need to know how I can change in my code so that it can scan one row at one time and display the result and then display onother and give the different result from the first one. ok
[no name] 30-Jul-13 13:29pm    
Your question and comment are not at all clear to me. But...
Why are you selecting all records from your database when you only want a single specific record?
Use parameterized queries.
Do not store your passwords in plain text.
DAVID DUSHIMIMANA 30-Jul-13 17:33pm    
Sir, I m not so good in this staff since I'm beginning working with vbnet, so what should I do? what it if I use fixed Service type where stand as Admin and User as role, and then I allow username and password to be changed due to registration of users . how should I do that,do selection of those items.

1 solution

You can go for ASP.NET Authorization[^].

Else you can apply your own logic, something like below...


  • Add one Role Table and relate that to the Login Table. For each User, there will be a row in Role Table.
  • At the time of Registration, you will insert row in Role Table.
  • At the time of Login, you will fetch the Role of User from Role Table.
  • According to the Role, you will then do your work.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900