hi

i have a database with a image(Binarycode)

and i want to select that image and infomation

i tryed like this but it says liki this

OledbExpaession unhandled
No value given for one or more required parameters.

my code like this

Imports System.Configuration
Public Class Form9
    Dim A As String = ConfigurationSettings.AppSettings("Datapath")
    Dim con1 As New OleDb.OleDbConnection(A)
    Dim com1 As OleDb.OleDbCommand

     Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        con1.Open()
        com1 = New OleDb.OleDbCommand("Select * from Employee where EId="+MaskedTextBox6.Text+"",con1)
        Dim rd As OleDb.OleDbDataReader
        rd = com1.ExecuteReader()
        If rd.Read = True Then


            ECODEMasked1.Text = rd.GetValue(0)
            MaskedTextBox5.Text = rd.GetValue(1)
            TextBox3.Text = rd.GetValue(2)
            TextBox4.Text = rd.GetValue(3)
            TextBox5.Text = rd.GetValue(4)
            TextBox6.Text = rd.GetValue(5)
            TextBox7.Text = rd.GetValue(6)
            TextBox8.Text = rd.GetValue(7)
            ENICMasked3.Text = rd.GetValue(8)
            DateTimePicker1.Value = rd.GetValue(9)
            ComboBox3.SelectedItem = rd.GetValue(10)
            ETeleMasked2.Text = rd.GetValue(11)
            TextBox10.Text = rd.GetValue(12)
            PictureBox1.Image = rd.GetValue(13)

        Else
            MsgBox("Record not Found", MsgBoxStyle.Information, "Search")

        End If
        con1.Close()






    End Sub


End Class

Are there any mistake?
plz help

i changed the code but it will dispaly the same Error message

i changed like follwing

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Try


            con1.Open()
            Dim arrImage() As Byte
            Dim myMS As New IO.MemoryStream
            Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM Employee " & _
                                          " WHERE EId=" & Me.MaskedTextBox6.Text, con1)

            'Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM tblstudent " & _
            '                           " WHERE stdid=" & Me.txtID.Text, cn)


            Dim dt As New DataTable
            da.Fill(dt)


            If dt.Rows.Count > 0 Then
                Me.ECODEMasked1.Text = dt.Rows(0).Item("EId") & ""
                If Not IsDBNull(dt.Rows(0).Item("Emp_Photo")) Then
                    arrImage = dt.Rows(0).Item("Emp_Photo")
                    For Each ar As Byte In arrImage
                        myMS.WriteByte(ar)
                    Next
                    '
                    Me.PictureBox1.Image = System.Drawing.Image.FromStream(myMS)
                End If

            Else
                MsgBox("Record not found!")
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try











        'Try
        '    PictureBox1.BackgroundImageLayout = ImageLayout.Stretch

        '    Dim sqlrt As String

        '    'com1.Connection = con1
        '    sqlrt = "select * from Employee where EID=@dtaEID"

        '    com1.CommandText = sqlrt
        '    com1.Connection = con1
        '    com1.Parameters.AddWithValue("@dtaEId", MaskedTextBox6.Text)

        '    Dim dr As OleDb.OleDbDataReader = com1.ExecuteReader()
        '    'dr

        '    dr.Read()
        '    If dr.HasRows Then
        '        Dim bits As Byte() = CType(dr("img"), Byte())
        '        Dim memo As New MemoryStream(bits)
        '        Dim myimg As New Bitmap(memo)



        '        'ECODEMasked1.Text = dr.GetValue(0)
        '        'MaskedTextBox5.Text = dr.GetValue(1)
        '        'TextBox3.Text = dr.GetValue(2)
        '        'TextBox4.Text = dr.GetValue(3)
        '        'TextBox5.Text = dr.GetValue(4)
        '        'TextBox6.Text = dr.GetValue(5)
        '        'TextBox7.Text = dr.GetValue(6)
        '        'TextBox8.Text = dr.GetValue(7)
        '        'ENICMasked3.Text = dr.GetValue(8)
        '        'DateTimePicker1.Value = dr.GetValue(9)
        '        'ComboBox3.SelectedItem = dr.GetValue(10)
        '        'ETeleMasked2.Text = dr.GetValue(11)
        '        'TextBox10.Text = dr.GetValue(12)
        '        PictureBox1.Image = myimg


        '    End If
        'Catch ex As Exception
        '    MsgBox(ex.ToString())

        'End Try
        'con1.Close()

        ' ''Try







        ' ''    com1 = New OleDb.OleDbCommand("Select * from Employee where EId= @EId", con1)
        ' ''    com1.Parameters.AddWithValue("@Eid", MaskedTextBox6.Text)
        ' ''    Dim pictureData As Byte() = DirectCast(com1.ExecuteScalar(), Byte())


        ' ''    Dim stream As New IO.MemoryStream(pictureData)


        ' ''    Dim rd As OleDb.OleDbDataReader
        ' ''    rd = com1.ExecuteReader
        ' ''    If rd.Read = True Then




        ' ''        ECODEMasked1.Text = rd.GetValue(0)
        ' ''        MaskedTextBox5.Text = rd.GetValue(1)
        ' ''        TextBox3.Text = rd.GetValue(2)
        ' ''        TextBox4.Text = rd.GetValue(3)
        ' ''        TextBox5.Text = rd.GetValue(4)
        ' ''        TextBox6.Text = rd.GetValue(5)
        ' ''        TextBox7.Text = rd.GetValue(6)
        ' ''        TextBox8.Text = rd.GetValue(7)
        ' ''        ENICMasked3.Text = rd.GetValue(8)
        ' ''        DateTimePicker1.Value = rd.GetValue(9)
        ' ''        ComboBox3.SelectedItem = rd.GetValue(10)
        ' ''        ETeleMasked2.Text = rd.GetValue(11)
        ' ''        TextBox10.Text = rd.GetValue(12)
        ' ''        PictureBox1.Image = Image.FromStream(stream)

        ' ''    Else
        ' ''        MsgBox("Record not Found", MsgBoxStyle.Information, "Search")

        ' ''    End If
        ' ''    con1.Close()

        ' ''Catch ex As Exception
        ' ''    MsgBox(ex.ToString())
        ' ''End Try




    End Sub
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.