seejr 0 Newbie Poster

Dear Members,
I am developing automatic image id creator using vs2008.Using excel file,folder images for image.Below is my code.I want all images to be place and printed seperately acording to the dtabase fetche from excel.Kindly help please.
Regards
JR

Imports System
 Imports System.ComponentModel
    Imports System.Drawing
    Imports System.IO
    Imports System.Runtime.CompilerServices
    Imports System.Windows.Forms[Click Here](null)
    Imports Microsoft.VisualBasic.CompilerServices
   Public Class Form1
           Dim i As Integer
            Dim openFileDialog2 As System.Windows.Forms.OpenFileDialog
            While True
                While True
                    Select Case i
                        Case 1
                            Dim openFileDialog1 As System.Windows.Forms.OpenFileDialog = New System.Windows.Forms.OpenFileDialog
                            openFileDialog1.Filter = "Supported files|*.xls;*.xlsx;*.csv?"
                            openFileDialog1.FilterIndex = 1
                            openFileDialog1.Title = "Select data file?"
                            openFileDialog2 = openFileDialog1
                            openFileDialog2.FileName = txtPath.Text
                            openFileDialog2.ShowDialog()
                            i = 2
                            GoTo label_1
                            Case 2
                            If Microsoft.VisualBasic.CompilerServices.Operators.CompareString(openFileDialog2.FileName, "?", False) = 0 Then
                                GoTo label_1
                            End If
                            i = 1
                    End Select
                End While
                If Not 0 Then
                End If
                txtPath.Text = openFileDialog2.FileName
                txtPath.ForeColor = System.Drawing.Color.Black
                i = 0
            End While
    label_1: _
    openFileDialog2 = Nothing
        End Sub
            Private Sub OpenFileDialog2_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog2.FileOk
            Dim strm As System.IO.Stream
            strm = OpenFileDialog2.OpenFile()
            TextBox1.Text = OpenFileDialog2.FileName.ToString()
            If Not (strm Is Nothing) Then
                'insert code to read the file data
                strm.Close()
                MessageBox.Show("file closed")
            End If
        End Sub
            Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click            
            OpenFileDialog2.Title = "Please Select a File"
            'OpenFileDialog2.InitialDirectory = "C:\"
            'OpenFileDialog2.Title = "Open a Text File"
            'OpenFileDialog2.ShowDialog()
            'OpenFileDialog2.InitialDirectory = "C:\Book11.xls"
            'OpenFileDialog2.Filter = "Excel Files(*.xls)|*.xls"
            OpenFileDialog2.Filter = "Excel|*.xls|Word Files|*.doc|Text|*.txt"
            ' OpenFileDialog2.ShowDialog()
            'OpenFileDialog2.Filter = "TextFile Files(*.text)|*.Text"
            OpenFileDialog2.ShowDialog()
            '===========================
            Dim MyConnection As System.Data.OleDb.OleDbConnection
            Dim DtSet As System.Data.DataSet
            Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
            'Dim cbo As DataGridViewComboBoxCell
            'MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Txt_Path.Text.ToString() + ";Extended Properties=Excel 8.0;")
            MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\TamilGrocery\Book1.xls';Extended Properties=Excel 8.0;")
            MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection)
            MyCommand.TableMappings.Add("Table", "Net-informations.com")
            DtSet = New System.Data.DataSet
            MyCommand.Fill(DtSet)
            DataGridView1.DataSource = DtSet.Tables(0)
            MyConnection.Close()
            'DataGridView1.Rows(0).Cells(0).Value = Image.FromFile("C:\TamilGrocery\WindowsApplication1\1.jpg")
            '================
            For i As Integer = 0 To DataGridView1.Columns.Count - 1
                ComboBox1.Items.Add(DataGridView1.Columns(i).Name)
            Next
            'Dim cmb As New DataGridViewComboBoxColumn()
            ' cmb.HeaderText = "ProID"
            'cmb.Name = "cmb"
            'cmb.MaxDropDownItems = 6
            ' cmb.Items.Add("True")
            ' cmb.Items.Add("False")
            ' DataGridView1.Columns.Add(cmb)
        End Sub
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            ' Dim img As New DataGridViewImageColumn()
            ' Dim inImg As Image = Image.FromFile("\C:\TamilGrocery\WindowsApplication1\Image\1000.jpg")
            ' img.Image = inImg
            ' DataGridView1.Columns.Add(img)
            ' img.HeaderText = "Image"
            'img.Name = "img"
            '================
            'DtSet.Tables(0).DefaultView.RowFilter = "Number LIKE" & txtNumber.Text & "'"
            'DataGridView1.DataSource = DtSet.Tables(0).DefaultView
            Dim textbox1 As New TextBox
            textbox1.Name = "Textbox1"
            textbox1.Size = New Size(170, 20)
            textbox1.Location = New Point(167, 32)
            GroupBox1.Controls.Add(textbox1)
            AddHandler textbox1.TextChanged, AddressOf Text_Changed
        End Sub
            Private Sub Text_Changed(ByVal eventSender As System.Object, _
                                 ByVal eventArgs As System.EventArgs)
            Dim txt As String = eventSender.Text
            If IsNumeric(txt) Then
                Else
                MessageBox.Show("Please enter numeric value")
            End If
        End Sub
            Private Sub DataGridView1_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting
            If e.ColumnIndex = 6 Then 'assumed third column is for image change the value based on what column your image need to bind
                If e.Value IsNot Nothing And Not TypeOf e.Value Is Bitmap Then
                    e.Value = Image.FromFile(IO.Path.Combine(Application.StartupPath, e.Value.ToString))
                    e.FormattingApplied = True
                End If
                End If
            End Sub
            Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'TODO: This line of code loads data into the 'DatabaseDataSet.Table1' table. You can move, or remove it, as needed.
           'Me.Table1TableAdapter.Fill(Me.DatabaseDataSet.Table1)
                ' Me.ReportViewer1.RefreshReport()
            End Sub
            Private Sub ReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
            End Sub
            Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
            End Sub
            Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            Dim textbox1 As New TextBox
            textbox1.Name = "Textbox1"
            textbox1.Size = New Size(170, 20)
            textbox1.Location = New Point(167, 32)
          GroupBox1.Controls.Add(textbox1)
            End Sub
            Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
            Dim label1 As New Label
            label1.Name = "label1"
            label1.Text = "Enter Name"
            label1.AutoSize = True
            label1.Location = New Point(80, 33)
            GroupBox1.Controls.Add(label1)
        End Sub
        End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.