bindingbindvb.net-2010

Cannot bind to the property IN VB.NET


I have a problem Unable to bind property. or because i have something wrong with my code.Please solution. I'm using visual studio 2010.

    Private Sub PopulateDataGridView()
        Try
            dt = New DataTable
            Dim query = "select ITM,ITC,QOH,PRS,PRSOBBRT,PRSOBNET,FILENAME1,FILENAME2,FILENAME3,FILENAME4,FILENAME5,FILENAME6 FROM IFG WHERE QOH > 0 AND SHI = @SHI"
            Using con As OleDbConnection = New OleDbConnection(cn)
                Using cmd As OleDbCommand = New OleDbCommand(query, con)
                    cmd.Parameters.AddWithValue("@SHI", ComboBox1.SelectedValue)
                    Using adapter As New OleDbDataAdapter(cmd)
                        'Dim dt As DataTable = New DataTable()
                        adapter.Fill(dt)
                        Me.DataGridView1.DataSource = dt
                    End Using
                End Using
            End Using
ExPictureBox1.PrePath = Pathimage & "\"
            ExPictureBox2.PrePath = Pathimage & "\"
            ExPictureBox3.PrePath = Pathimage & "\"
            ExPictureBox4.PrePath = Pathimage & "\"
            ExPictureBox5.PrePath = Pathimage & "\"
            ExPictureBox6.PrePath = Pathimage & "\"

            ExPictureBox1.DataBindings.Add("FileName", dt, "FILENAME1") 
            ExPictureBox2.DataBindings.Add("FileName", dt, "FILENAME2")
            ExPictureBox3.DataBindings.Add("FileName", dt, "FILENAME3")
            ExPictureBox4.DataBindings.Add("FileName", dt, "FILENAME4")
            ExPictureBox5.DataBindings.Add("FileName", dt, "FILENAME5")
            ExPictureBox6.DataBindings.Add("FileName", dt, "FILENAME6")
Catch myerror As OleDbException
            MessageBox.Show("Error: " & myerror.Message)
        Finally
        End Try
    End Sub

Cannot bind to the property

bindings in the collection thanks roy


Solution

  • Private Sub PopulateDataGridView()
            Try
                dt = New DataTable
                Dim query = "select ITM,ITC,QOH,PRS,PRSOBBRT,PRSOBNET,FILENAME1,FILENAME2,FILENAME3,FILENAME4,FILENAME5,FILENAME6 FROM IFG WHERE QOH > 0"
                Using con As OleDbConnection = New OleDbConnection(cn)
                    Using cmd As OleDbCommand = New OleDbCommand(query, con)
                        Using adapter As New OleDbDataAdapter(cmd)
                            adapter.Fill(dt)
                            Me.DataGridView1.DataSource = dt
                        End Using
                    End Using
                End Using
    ExPictureBox1.PrePath = Pathimage & "\"
                ExPictureBox2.PrePath = Pathimage & "\"
                ExPictureBox3.PrePath = Pathimage & "\"
                ExPictureBox4.PrePath = Pathimage & "\"
                ExPictureBox5.PrePath = Pathimage & "\"
                ExPictureBox6.PrePath = Pathimage & "\"
    
                ExPictureBox1.DataBindings.Add("FileName", dt, "FILENAME1") 
                ExPictureBox2.DataBindings.Add("FileName", dt, "FILENAME2")
                ExPictureBox3.DataBindings.Add("FileName", dt, "FILENAME3")
                ExPictureBox4.DataBindings.Add("FileName", dt, "FILENAME4")
                ExPictureBox5.DataBindings.Add("FileName", dt, "FILENAME5")
                ExPictureBox6.DataBindings.Add("FileName", dt, "FILENAME6")
    Catch myerror As OleDbException
                MessageBox.Show("Error: " & myerror.Message)
            Finally
            End Try
        End Sub