May i ask how to using open file dialog read mdb database without know datatable

  • Thread starter Thread starter christing
  • Start date Start date
C

christing

Guest
i am writing open file dialog read mdb without know data table and show it at datagridview.

below is the code i trying to write

Using OpenFileDialog1 As New OpenFileDialog()
OpenFileDialog1.InitialDirectory = "D:\"
OpenFileDialog1.Filter = "Access files (*.mdb)|*.mdb"
OpenFileDialog1.FilterIndex = 0
OpenFileDialog1.RestoreDirectory = True
If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Try
Dim FileName As String = OpenFileDialog1.FileName
Dim AccessConnection As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & FileName)

AccessConnection.Open()
'...
'...
Catch Ex As Exception
MessageBox.Show("Cannot read file. Original error: " & Ex.Message)
End Try
End If
End Using
End Sub

i am no idea how to write a code and show it on datagridview. can somenone guide me thanks .

Continue reading...
 
Back
Top