Hi my login page works fine, until i run it again yesterday.. Below is the error it gave.. Any kind soul please help.. I'm a still beginner.. Thanks alot!
An unhandled exception of type 'System.InvalidCastException' occurred in system.data.dll
Additional information: The data value could not be converted for reasons other than sign mismatch or data overflow. For example, the data was corrupted in the data store but the row was still retrievable.
Below is my code.. the error points to the line in red :
An unhandled exception of type 'System.InvalidCastException' occurred in system.data.dll
Additional information: The data value could not be converted for reasons other than sign mismatch or data overflow. For example, the data was corrupted in the data store but the row was still retrievable.
Below is my code.. the error points to the line in red :
VB.NET:
Dim strUser, strPass, strConn As String
Dim frmMain As New frmHome
Dim dbcon As New OleDbConnection
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
strConn += "Data Source=Computer Store.mdb;User Id=Admin; Password=;"
dbcon.ConnectionString = strConn
'set up query statement
strUser = "Select * from Storer where StorerID='" & Me.txtUser.Text.Trim & "'"
'create an instance of a command
Dim cmdSelectCommand As New OleDbCommand(strUser, dbcon)
dbcon.Open()
'execute command
Dim dtLogin As OleDbDataReader = cmdSelectCommand.ExecuteReader
'Reader will return a TRUE if the username matches
If (dtLogin.Read() = True) Then
Dim tempUser, tempPass As String
tempUser = dtLogin.Item("StorerID")
tempPass = dtLogin.Item("EmpPassword")
Dim PrivAccess As Short
[COLOR=red]PrivAccess = dtLogin.GetInt16(dtLogin.GetOrdinal("EmpPrivilege"))[/COLOR]
If PrivAccess = 1 Then
MessageBox.Show("Level 1, Login OK!")
Me.Visible = False
frmMain.ShowDialog()
Me.Visible = True
Me.txtUser.Clear()
Me.txtPass.Clear()
Me.txtUser.Focus()
Else
MessageBox.Show("Level 2, Login OK")
Me.Visible = False
frmMain.btnCustOrder.Enabled = False
frmMain.btnCustOrder.Visible = False
frmMain.ShowDialog()
Me.Visible = True
Me.txtUser.Clear()
Me.txtPass.Clear()
Me.txtUser.Focus()
End If
Else
MessageBox.Show("Login Fail! Please Try Again.", "Login", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
Me.txtUser.Clear()
Me.txtPass.Clear()
Me.txtUser.Focus()
End If
dtLogin.Close()
dbcon.Close()
Last edited by a moderator: