Getting error while using openfiledialog

-2

Sorry for my incomplete information.. I am trying to explain my problem step by step.

Problem: I have made 3 forms, Form1, Form2, and Form3. In Form2 i have drag 1 button for browsing the file, for that i have used Openfiledialog .Net component. when debug starts (Form1 load first) and clicked on that particular button in form2 error message comming which is as below..

"System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'"

"System.AccessViolationException HResult=0x80004003 Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Source= StackTrace: "

What Containing in Forms: Form1: 1. used two buttons for calling form1 and form2. Codes are below,

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click form2.show() Me.Hide() End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    form3.show()
    Me.Hide()
End Sub
  1. Datagridview which is connected to Access accdb database, Codes for Form1 load event as below,

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'Database1DataSet.Table1' table. You can move, or remove it, as needed. Me.Table1TableAdapter.Fill(Me.Database1DataSet.Table1) End Sub

Form2: 1. Used three buttons a. Buttons 1 and 2 for calling Form1 and Form3 respectively. Codes are below,

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Form1.Show()
    Me.Hide()
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    Form3.Show()
    Me.Hide()
End Sub

b. Button 3 for browsing the file, i have used very simple code for only testing, Codes are below

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click OpenFileDialog1.ShowDialog() End Sub

  1. Datagridview which is connected to same database and same table, Codes are below

    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'Database1DataSet.Table1' table. You can move, or remove it, as needed. Me.Table1TableAdapter.Fill(Me.Database1DataSet.Table1) End Sub

Form3: 1. Two Buttons: used for calling Form1 and Form2, Code are below,

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Form1.Show() Me.Hide() End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    Form2.Show()
    Me.Hide()
End Sub
  1. Datagridview which is connected to same Database and same Table (as Form1 and Form2), Codes are below,

    Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'Database1DataSet.Table1' table. You can move, or remove it, as needed. Me.Table1TableAdapter.Fill(Me.Database1DataSet.Table1) End Sub

More Information: when i inactive the Database connecting code in all forms, there is a no problem.

vb.net
openfiledialog
asked on Stack Overflow Aug 7, 2018 by Barun • edited Aug 8, 2018 by Barun

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0