How to browse MDB file in DataGridView and TIF Images in ImageViewer?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jhamjhamqt
    New Member
    • Jan 2016
    • 9

    How to browse MDB file in DataGridView and TIF Images in ImageViewer?

    Code:
    Imports System.IO
    Imports System.Data
    Imports System.Data.OleDb
    Imports Microsoft.VisualBasic
    
    
    Public Class CARD_DECK_ENTRY Public myConString As String Dim con As New OleDb.OleDbConnection Dim myStream As Stream = Nothing
    
    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        End
        Operator_ID.Close()
    End Sub
    
    Private Sub OpenFileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenFileToolStripMenuItem.Click
    
        Dim openFileDialog1 As New OpenFileDialog()
    
        openFileDialog1.InitialDirectory = "c:\"
        openFileDialog1.Filter = "mdb files (*.mdb)|*.mdb|All files (*.*)|*.*"
        openFileDialog1.FilterIndex = 1
        openFileDialog1.RestoreDirectory = True
    
    
        If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            Try
                myStream = openFileDialog1.OpenFile()
                If (myStream IsNot Nothing) Then
                    myConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & openFileDialog1.FileName
                    Dim x As String = openFileDialog1.FileName.Substring(0, openFileDialog1.FileName.Length - 20) & "Images"
                    con.ConnectionString = myConString
                    con.Open()
    
                    datagridshow()
                End If
            Catch Ex As Exception
                MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)
            Finally
                ' Check this again, since we need to make sure we didn't throw an exception on open. 
    
                If (myStream IsNot Nothing) Then
                    myStream.Close()
                End If
            End Try
        End If
    
    End Sub
    
    
    Private Sub CARD_DECK_ENTRY_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
        con.ConnectionString = myConString
    
        con.Open()
    
        datagridshow()
    
    End Sub
    
    Private Sub datagridshow()
        Dim ds As New DataSet
        Dim dt As New DataTable
        ds.Tables.Add(dt)
        Dim da As New OleDbDataAdapter
    
        da = New OleDbDataAdapter("Select * from Data001", con)
        da.Fill(dt)
    
        DataGridView1.DataSource = dt.DefaultView
    
        con.Close()
    
    
    End Sub
    ---

    The above codes was to browse an MDB file and it worked, but now i'm about to load the images into a imageViewer with same time on browsing mdb. As you can see in the above codes, there was ("Select * from Data001", con) because it was a table I will be showing on the DataGridView. On the database there was a two table, those are "CardDeck" and "Data001." In CardDeck there was a "Image001" column. This column contains tif image names. On the folder where the database was found there was another folder on the same path(path of the database folder) named "Images". The column value of "Image001" will be found there. My point is how can I browse those "Image001" column value to a ImageViewer where those value are located in Folder "Images"? Please help. :'(
    Last edited by Rabbit; Jan 28 '16, 06:53 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
Working...