Jump to content

Multi user access login

- - - - -

  • Please log in to reply
3 replies to this topic

#1
iswan

iswan

    Newbie

  • Members
  • Pip
  • 5 posts
hai i got an error in my coding,The error is expression expected . Please advice me how i am to correct my coding.Here is my coding which is connected to database .In my coding , i create 3 textbox which is txtusername.text, txtpassword.text and txtdepartment.text. User must key in they username ,password and their department in the login page, if the user department is Admin then he will access into
admin page and if user department is store then he will access into store page. I am still new beginner in this vb language and for your info i am using visual studio 2005 and sql 2005.Here is my code and my interface

Public Class Form1
Dim r = Me.StaffTableAdapter
Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click

Dim r = Me.StaffTableAdapter.UsernamePassword(Me.txtusername.Text, Me.txtpassword.Text, Me.txtdepartment.Text)
If r me.txtdepartment.text is Caunter Then
counter.Show()
else if
me.txtdepartment.Text is Admin Then
Admin.Show()
else if
me.txtdepartment.text is store then
store.Show()

End If
MsgBox("invalid username and password")

End Sub

Private Sub StaffBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StaffBindingNavigatorSaveItem.Click
Me.Validate()
Me.StaffBindingSource.EndEdit()
Me.StaffTableAdapter.Update(Me.StaffDataSet.staff)

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'StaffDataSet.staff' table. You can move, or remove it, as needed.
Me.StaffTableAdapter.Fill(Me.StaffDataSet.staff)

End Sub
End Class


#2
Blimp

Blimp

    Programmer

  • Members
  • PipPipPipPip
  • 154 posts
[B]Public Class Form1
    Dim r = Me.StaffTableAdapter
    Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click

        Dim r = Me.StaffTableAdapter.UsernamePassword(Me.txtuserna  me.Text, Me.txtpassword.Text, Me.txtdepartment.Text)

        [/B][COLOR=#ff0000]If r me.txtdepartment.text is Caunter Then
            counter.Show()
   else if
              me.txtdepartment.Text is Admin Then
            Admin.Show()
       else if
             me.txtdepartment.text is store then
            store.Show()

        End If[/COLOR][B]
        MsgBox("invalid username and password")

    End Sub

    Private Sub StaffBindingNavigatorSaveItem_Click(ByVal sender As  System.Object, ByVal e As System.EventArgs) Handles  StaffBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.StaffBindingSource.EndEdit()
        Me.StaffTableAdapter.Update(Me.StaffDataSet.staff)

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'StaffDataSet.staff' table. You can move, or remove it, as needed.
        Me.StaffTableAdapter.Fill(Me.StaffDataSet.staff)

    End Sub
End Class[/B]


me.txtdepartment.text is a string and therefore needs to be matched with as string.

Replace the

is Caunter 

with

= "Caunter"

And do that so on for each department.

#3
iswan

iswan

    Newbie

  • Members
  • Pip
  • 5 posts

Blimp said:

[B]Public Class Form1

    Dim r = Me.StaffTableAdapter

    Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click


        Dim r = Me.StaffTableAdapter.UsernamePassword(Me.txtuserna  me.Text, Me.txtpassword.Text,  Me.txtdepartment.Text)


        [/B][COLOR=#ff0000]If r me.txtdepartment.text is Caunter Then

            counter.Show()

   else if

              me.txtdepartment.Text is Admin Then

            Admin.Show()

       else if

             me.txtdepartment.text is store then

            store.Show()


        End If[/COLOR][B]

        MsgBox("invalid username and password")


    End Sub


    Private Sub StaffBindingNavigatorSaveItem_Click(ByVal sender As  System.Object, ByVal e As System.EventArgs) Handles  StaffBindingNavigatorSaveItem.Click

        Me.Validate()

        Me.StaffBindingSource.EndEdit()

        Me.StaffTableAdapter.Update(Me.StaffDataSet.staff)


    End Sub


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'TODO: This line of code loads data into the 'StaffDataSet.staff' table. You can move, or remove it, as needed.

        Me.StaffTableAdapter.Fill(Me.StaffDataSet.staff)


    End Sub

End Class[/B]


me.txtdepartment.text is a string and therefore needs to be matched with as string.

Replace the

is Caunter 

with

= "Caunter"

And do that so on for each department.

Hai i got an error end of statement expected in my code here. Please advice me where should i correct my mistake here is my code.I also have bold the line which i got probleam

Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click

Dim r = Me.StaffTableAdapter.UsernamePassword(Me.txtusername.Text, Me.txtpassword.Text, Me.txtdepartment.Text)
If r me.txtdepartment.text = " Caunter" Then
counter.Show()

ElseIf Me.txtdepartment.Text = " Admin" Then
Admin.Show()
ElseIf Me.txtdepartment.Text = "Store" Then
store.Show()

End If
MsgBox("invalid username and password")

End Sub

#4
Blimp

Blimp

    Programmer

  • Members
  • PipPipPipPip
  • 154 posts

iswan said:

Hai i got an error end of statement expected in my code here. Please advice me where should i correct my mistake here is my code.I also have bold the line which i got probleam

Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click

Dim r = Me.StaffTableAdapter.UsernamePassword(Me.txtusername.Text, Me.txtpassword.Text, Me.txtdepartment.Text)
If r me.txtdepartment.text = " Caunter" Then
counter.Show()

ElseIf Me.txtdepartment.Text = " Admin" Then
Admin.Show()
ElseIf Me.txtdepartment.Text = "Store" Then
store.Show()

End If
MsgBox("invalid username and password")

End Sub


People like you really need to brush up your programming- You have a space before the Caunter.. What is a caunter anyway?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users