Electronics Lab Philippines

vb .net login, case sensitive

Offline bibang

  • *****
  • 142
  • 2
  • Gender: Male
  • likeaboss c:
vb .net login, case sensitive
« on: February 17, 2013, 06:35:54 PM »
sir i had made a login form in vb 2010 and ms sql server 2008 to store and retreive datas, my question is for example the pass word registered is "bibang" but when i input "BIBANG" it will still logs in, how to set this so that it will only accept passwords that are really registered on my database, it shuld be case sensitive ofc. thank you
bakasibibangyan <3

Re: vb .net login, case sensitive
« Reply #1 on: February 19, 2013, 09:47:08 AM »
Quote
Dim uname As String

Dim pwd As String

uname = InputBox("Enter username…", " Enter Username", "username") 

If uname = "PrODo" Then 'uname match string

    pwd = InputBox("Enter password…", " Enter Password", "pass") 

    If pwd = "paSSWord" Then

        MsgBox("I grAnt thEe!") 

    Else

        MsgBox("THOU SHALL NOT PASS!!") 

        me.close()

    End If

Else

    MsgBox("THOU SHALL NOT PASS") 

    me.close() 

End If
-Spoon feeding in the long run teaches us nothing but the shape of the spoon

Offline bibang

  • *****
  • 142
  • 2
  • Gender: Male
  • likeaboss c:
Re: vb .net login, case sensitive
« Reply #2 on: February 19, 2013, 11:36:33 AM »
is it also applicable if there are lot of users registered? thnks
bakasibibangyan <3

Re: vb .net login, case sensitive
« Reply #3 on: February 19, 2013, 02:28:44 PM »
gamit ka na ng simple storage mo nun kung saan naka store ung mga accounts na icacall mo


Quote
Public Class loginFRM

    Private Sub login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles login.Click
        Dim uname, pwd As String
        Dim dataread As sqlDataReader
        Dim com As New sqlCommand

        uname = Txtuser.Text.trim
        pwd = Txtpwd.Text.trim

        Sql = "SELECT [USERNAMECOLUMN] FROM [ACCOUNTSTABLE] WHERE [USERNAMECOLUMN]='" & uname & "' AND [PASSWORDCOLUMN]='" & pwd & "'"
        com.CommandText = Sql
        com.Connection = con
        MsgBox(Sql)
        If con.State = ConnectionState.Closed Then con.Open()
        'adding few variables
        Dim readuname, readpwd As String = ""
        dataread = com.ExecuteReader
        While dataread.Read()
            readuname = dataread.Item("[Username Column]")
            readpwd = dataread.Item("[Password Column]")
        End While
        'Now check if these two values are the same
        If readuname = uname AndAlso readpwd = pwd AndAlso readuname = "" AndAlso readpwd = "" Then
            LS = True
            [your FORM].Show()
            Me.Hide()
        Else
            MessageBox.Show("THOU SHALL NOT PASS!!!", "Login Fail", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End If
    End Sub

End Class
-Spoon feeding in the long run teaches us nothing but the shape of the spoon