vincent mapalala

vincent mapalala

  • 2k
  • 13
  • 12.8k

hi guys, plse plse help me to retieve image stored in sqldb field name is picture, my code is below, am student learning visuel

Nov 16 2010 4:17 AM

myconnection = New SqlConnection("server=(local);Initial Catalog=stock;Integrated Security=SSPI")



        mycommand = New SqlCommand("select cartype,eng,color,price,year,extras,picture,carname from info where sno='" + txtsno.Text + "'", myconnection)

        dr = mycommand.ExecuteReader

        While dr.Read()

            txttype.Text = dr("cartype").ToString()

            txteng.Text = dr("eng").ToString()

            txtcolor.Text = dr("color").ToString()

            txtcarname.Text = dr("carname").ToString()

            txtprice.Text = dr("price").ToString()

            txtyear.Text = dr("year").ToString()

            txtextras.Text = dr("extras").ToString()

txtpics.Text = dr("picture").ToString()


        End While


        Dim da As New System.Data.SqlClient.SqlDataAdapter(mycommand)

        Dim ds As New DataSet()



        Dim bits As Byte() = CType(ds.Tables("info").Rows(0)("picture"), Byte())

        Dim memorybits As New IO.MemoryStream(bits)

        Dim bitmap As New Bitmap(memorybits)

        PictureBox1.Image = bitmap


iwant to display image stored in picture field  bt am gettinf error, plse help me to do this

Brought to you by:

Answers (3)