SecurityException was Unhandled

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jtnpham@gmail.com

    SecurityException was Unhandled

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

    Private Sub btnAdd_Click(By Val sender As Object, ByVal e As
    System.EventArg s) 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.o ledb.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.OleDbData Adapter(sqlStr, connStr)
    dataadapter.Fil l(dt)
    dataadapter.Dis pose()

    End Sub

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

    Can anyone help me?

    Thanks!

  • Michael M.

    #2
    Re: SecurityExcepti on was Unhandled

    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
    <jtnpham@gmail. comwrote in message
    news:1172675312 .062205.180130@ k78g2000cwa.goo glegroups.com.. .
    This is code I created to add a record where the user inputs the new
    text in textboxes:
    >
    Private Sub btnAdd_Click(By Val sender As Object, ByVal e As
    System.EventArg s) 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.o ledb.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.OleDbData Adapter(sqlStr, connStr)
    dataadapter.Fil l(dt)
    dataadapter.Dis pose()
    >
    End Sub
    >
    When I run the program it stops at dataadapter.Fil l(dt) and gives me
    the error message: Security Exception was Unhandled.
    >
    Can anyone help me?
    >
    Thanks!
    >

    Comment

    • jtnpham@gmail.com

      #3
      Re: SecurityExcepti on was Unhandled

      where do i go to change it to "trusted"?

      Comment

      • Michael M.

        #4
        Re: SecurityExcepti on was Unhandled

        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.


        <jtnpham@gmail. comwrote in message
        news:1173112878 .994159.73700@n 33g2000cwc.goog legroups.com...
        where do i go to change it to "trusted"?
        >

        Comment

        Working...