i have a problem with the length of fields in a sql data table
let me say i have 3 fields in this table username, userpass and userid
all with the length of 10 bytes
on a form i have 2 textboxes for the username and the userpass
i want to compare if the username and the userpass matches the values in the database. i do this with a datareader code below
in the databes there is one record stored userid = 1 username = ADMIN and userpass = admin
but if i try to compare these two values with the values the user entered i always get loggedin to false because of the length of the values. the length in the textboxes if i type in ADMIN is 5 and the length in the database for ADMIN is 10 so how can i compare these values without the left spaces in the database?
let me say i have 3 fields in this table username, userpass and userid
all with the length of 10 bytes
on a form i have 2 textboxes for the username and the userpass
i want to compare if the username and the userpass matches the values in the database. i do this with a datareader code below
Code:
mainconn.Open()
sel = New SqlCommand("SELECT * FROM users WHERE username=" & username & "", mainconn)
Dim userread As SqlDataReader = sel.ExecuteReader()
userread.Read()
If userread.Item("Username") = username And userread.Item("Userpass") = password Then
userid = userread.Item("userid")
loggedin = True
username = username
Else
loggedin = False
End If
useradap.Close()
Return loggedin
in the databes there is one record stored userid = 1 username = ADMIN and userpass = admin
but if i try to compare these two values with the values the user entered i always get loggedin to false because of the length of the values. the length in the textboxes if i type in ADMIN is 5 and the length in the database for ADMIN is 10 so how can i compare these values without the left spaces in the database?