SecurityException was Unhandled

J

jtnpham

This is code I created to add a record where the user inputs the new
text in textboxes:

Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
City = txtCity.Text
Country = txtCountry.Text
p2005 = txt2005.Text
p2015 = txt2015.Text

Dim dt As New DataTable()
Dim connStr As String = "Provider = Microsoft.Jet.oledb.4.0;"
& "Data Source=F:\Pham\megacities.mdb"
Dim sqlStr As String = "INSERT INTO Cities VALUES('city',
'country', 'p2005', 'p2015')"
Dim dataadapter As New OleDb.OleDbDataAdapter(sqlStr, connStr)
dataadapter.Fill(dt)
dataadapter.Dispose()

End Sub

When I run the program it stops at dataadapter.Fill(dt) and gives me
the error message: Security Exception was Unhandled.

Can anyone help me?

Thanks!
 
M

Michael M.

Are you running it from a network, or accessing a network resource to load
the database?

If so you may need to change settings on the computer to "Trust" the
assembly

Mike
 
M

Michael M.

In the control panel -> microsoft.net configuration wizards icon "Runtime
security policy"

I can not explain the exact steps as I find this console quite complex
myself, but this is where you get it done.

I tend not to run .NET applications from a network share for this reason.

Mike.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top