gwosgood
asked on
Request for OleDbPermission failed
Hello Coders.
Im trying to design a login form for a VB.Net 2005 project and im running into some problems along the way. I am reading data from a locally-stored Access 2003 database. Below is the sample code.
Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles cmdLogin.Click
Dim UserName As String
Dim Password As String
UserName = txtUserName.Text
Password = txtPassword.Text
Dim myConnection As New OleDb.OleDbConnection("Pro vider = Microsoft.Jet.OLEDB.4.0;Da ta Source = C:\Documents and Settings\dfranczyk\Desktop \Precision Security.m db")
Dim drUserID As OleDb.OleDbDataReader
myConnection.Open()
Dim insertCmd As New OleDb.OleDbCommand("Select * From Employee Where UserID= '" & UserName _
& "' AND Password = '" & Password & "'", myConnection)
Try
drUserID = insertCmd.ExecuteReader()
While drUserID.Read
MsgBox("Validated!", MsgBoxStyle.OkOnly, "Success")
frmMain.Show()
Me.Hide()
End While
Catch ex As OleDb.OleDbException
MsgBox(ex.Message)
MsgBox("Test Failed", MsgBoxStyle.OkOnly)
Finally
End Try
myConnection.Close()
End Sub
When I try to run the above code, I get an error on this statement:
myConnection.Open()
Here is the error message:
Request for the permission of type 'System.Data.OleDb.OleDbPe rmission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c56193 4e089' failed.
Any idea of what I am doing wrong? Any advice or suggestions would be greatly appreciated. Thanks for your time.
Im trying to design a login form for a VB.Net 2005 project and im running into some problems along the way. I am reading data from a locally-stored Access 2003 database. Below is the sample code.
Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles cmdLogin.Click
Dim UserName As String
Dim Password As String
UserName = txtUserName.Text
Password = txtPassword.Text
Dim myConnection As New OleDb.OleDbConnection("Pro
Dim drUserID As OleDb.OleDbDataReader
myConnection.Open()
Dim insertCmd As New OleDb.OleDbCommand("Select
& "' AND Password = '" & Password & "'", myConnection)
Try
drUserID = insertCmd.ExecuteReader()
While drUserID.Read
MsgBox("Validated!", MsgBoxStyle.OkOnly, "Success")
frmMain.Show()
Me.Hide()
End While
Catch ex As OleDb.OleDbException
MsgBox(ex.Message)
MsgBox("Test Failed", MsgBoxStyle.OkOnly)
Finally
End Try
myConnection.Close()
End Sub
When I try to run the above code, I get an error on this statement:
myConnection.Open()
Here is the error message:
Request for the permission of type 'System.Data.OleDb.OleDbPe
Any idea of what I am doing wrong? Any advice or suggestions would be greatly appreciated. Thanks for your time.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.