0
我需要上傳和顯示圖像數據庫。我已經寫了這個代碼上傳,它上傳的罰款。除了1個問題。它崩潰時,我不選擇一個圖像。有人可以幫我解決它的空值?你怎麼在IE中顯示圖像?用於插入圖像從sql server數據庫插入和顯示圖像在vb.net
代碼 -
Dim imageInfo As FileInfo = Nothing
Dim data() As Byte = Nothing
imageInfo = New FileInfo(Me.UploadLogo.Value.Trim())
Dim imagestream As FileStream = New FileStream(imageInfo.ToString, FileMode.Open)
if name_id > 0
ReDim data(imagestream.Length - 1)
imagestream.Read(data, 0, imagestream.Length)
imagestream.Close()
Sqlstr = "UPDATE logos WITH(ROWLOCK) " & _
"SET [email protected],Modified_Date=GETDATE() " & _
"WHERE ID = " + name_id.ToString + ""
Else
Sqlstr = "INSERT logos (Logo,Created_Date) " & _
"VALUES ("@Logo,GETDATE())"
End If
SqlCmd = New SqlCommand(Sqlstr, SqlCnn)
Dim pictureParameter As SqlParameter = Nothing
pictureParameter = New SqlParameter("@Logo", SqlDbType.Image)
pictureParameter.Value = data
SqlCmd.Parameters.Add(pictureParameter)
SqlCmd.ExecuteScalar()
這隻有當一個圖像被選擇細,爲崩潰NULL值。 也請幫助我與圖像顯示。感謝