我好象是从数据库中提取出来了,可是显示的时候只有一个图像的位置,却不显示图像出来,是什么原因或者大家有成功的例子可以写出来吗?

解决方案 »

  1.   

    将数据库中的图片读出并显示在Image控件中
    Dim sqlconn As New SqlConnection("Data Source=.;Initial Catalog=MyPhoto;Persist Security Info=True;User ID=lgh;password=800913")
    sqlconn.Open()
    Dim sqlComm As New SqlCommand("SELECT Photo FROM tbPhoto WHERE NoNum=5", sqlconn)
    sqlComm.CommandType = CommandType.Text
    Dim dataReader As SqlDataReader = sqlComm.ExecuteReader(CommandBehavior.SingleRow)
    If dataReader.Read Then
         If Not IsDBNull(dataReader.Item(0)) Then
              Dim bt() As Byte = dataReader.Item(0)
              Dim ms As MemoryStream = New MemoryStream(bt)
              PictureBox1.Image = Image.FromStream(ms)
          Else
              MsgBox("无图片")
        End If
    Else
         MsgBox("无数据")
    End If
    dataReader.Close()
    dataReader = Nothing
     sqlComm = Nothing
     sqlconn.Close()
      

  2.   

    参看
    http://blog.csdn.net/knight94/archive/2006/03/31/645987.aspx