Private Sub cmdLogin_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cmdLogin.Click

'Declare connection string and assign
'a value to it.
Dim str1 As String = "Data Source=PROSERVER;" & _
"Initial Catalog=SqlMagMemberApp;" & _
"Integrated Security=SSPI"

'Instantiate a connection.
Dim cnn1 As SqlClient.SqlConnection = _
New SqlClient.SqlConnection(str1)

'Declare command to validate MemberID and
Dim cmd1 As SqlClient.SqlCommand = cnn1.CreateCommand
cmd1.CommandType = CommandType.StoredProcedure
cmd1.CommandText = "IsValidMember"
Dim prm1 As SqlClient.SqlParameter = _
cmd1.Parameters.Add("@OK", SqlDbType.Int)
prm1.Direction = ParameterDirection.ReturnValue

Dim prm2 As SqlClient.SqlParameter = _
cmd1.Parameters.Add("@inID", SqlDbType.NVarChar, 8)
prm2.Direction = ParameterDirection.Input

Dim prm3 As SqlClient.SqlParameter = _
cmd1.Parameters.Add("@inpassword", SqlDbType.NVarChar, 30)
prm3.Direction = ParameterDirection.Input

Dim prm4 As SqlClient.SqlParameter = _
cmd1.Parameters.Add("@inMemberlw", SqlDbType.NVarChar, 15)
prm4.Direction = ParameterDirection.Input

prm2.Value = txtMemberID.Text
prm3.Value = txtPassword.Text
prm4.Value = listMemberLW.Text


'Accept the return value:
'1 if valid
'0 otherwise
Dim count As Byte = _
If count = 1 Then
Session("MemberID") = txtMemberID.Text
Session("MemberPW") = txtPassword.Text
Session("LoggedIn") = True

this is my code i have used storedprocedure to check id and password..
but the fault is the password and id accepts if typed with capslock on or off..
i hope u understand my query

Recommended Answers

All 3 Replies

please i need the result as quickly as possible

generally, people are only concerned with case sensitivity for passwords, not username. so what i like to do is
Dim SELSTRING as String

SELSTRING = "Select PASSWORD from DBUSERS where username = '" & textbox1.text & "' AND Password = '" & textbox2.text & "'"
Dim DBCOMMAND as new data.sqlclient.command(SELSTRING, conn1)

dim pw as string
pw = DBCOMMAND.executescalar

This returns the password as a string
now, you can compare the passwords

if textbox2.text = pw then
textbox2.backcolor = or whatever
end if
pw =

please i need the result as quickly as possible

You can use the string conversion in VB.NET ToUpper to convert to all upper case, before comparing to the database, or use ToProper which will capitolize the first letter of each string of text, but not really good, if you have a name like McDoogal or some other upper and lower case and finally you could use the ToLower and make all your letter lower and it won't matter how they enter it into the textboxes.

You can also use the same feature when they create their user names and passwords to store the data in your database properly for comparisons.

txtName.ToUpper = all UPPER case letters
txtName.ToLower = all lower case letters
txtName.ToProper = all Proper Case letter

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.