paulhudson
Programmer
I have a logon page which has three textboxes. On clicking submit the following procedure is called.
Needless to say it fails. Essentially I am trying to count a number of records that match username
password etc from within an access database. If the count is one then the logon is a success.
The problem occurs here:
Count = Convert.ToInt32(oCommand.ExecuteScalar())
With the following error message "Data type mismatch in criteria expression"
Here is the code:
sub Submit(obj as Object, e as EventArgs)
Dim RedirectPage As String
If tbTeam.text = "Club" then
RedirectPage = "ClubAdmin.aspx"
Else
RedirectPage = "TeamAdmin.aspx"
End If
Dim sSQL = "select count(*) from tbusers where username='" & tbUsername.text & "' AND password='" & tbPassword.text & "' AND TeamType='" & tbTeam.text & "';"
Dim oConnect As New OleDbConnection(ConfigurationSettings.AppSettings("connString"))
Dim oCommand As New OleDbCommand(sSQL, oConnect)
Dim Count As Int32
Count = "0"
oConnect.Open()
Count = Convert.ToInt32(oCommand.ExecuteScalar())
oConnect.Close()
Dim LoginCount As Label
LoginCount.Text = Count.ToString()
If LoginCount.Text = "1" Then
Session("Authorized") = "yes"
Session("TeamType") = tbTeam.Text
Session("Username") = tbUsername.Text
Else
lblmessage.text = "Please verify your login information."
End If
End Sub
Needless to say it fails. Essentially I am trying to count a number of records that match username
password etc from within an access database. If the count is one then the logon is a success.
The problem occurs here:
Count = Convert.ToInt32(oCommand.ExecuteScalar())
With the following error message "Data type mismatch in criteria expression"
Here is the code:
sub Submit(obj as Object, e as EventArgs)
Dim RedirectPage As String
If tbTeam.text = "Club" then
RedirectPage = "ClubAdmin.aspx"
Else
RedirectPage = "TeamAdmin.aspx"
End If
Dim sSQL = "select count(*) from tbusers where username='" & tbUsername.text & "' AND password='" & tbPassword.text & "' AND TeamType='" & tbTeam.text & "';"
Dim oConnect As New OleDbConnection(ConfigurationSettings.AppSettings("connString"))
Dim oCommand As New OleDbCommand(sSQL, oConnect)
Dim Count As Int32
Count = "0"
oConnect.Open()
Count = Convert.ToInt32(oCommand.ExecuteScalar())
oConnect.Close()
Dim LoginCount As Label
LoginCount.Text = Count.ToString()
If LoginCount.Text = "1" Then
Session("Authorized") = "yes"
Session("TeamType") = tbTeam.Text
Session("Username") = tbUsername.Text
Else
lblmessage.text = "Please verify your login information."
End If
End Sub