及其我的處理程序(ashx的)不能在圖像控制顯示圖像
Dim EmployeeID As Integer
If (Not (context.Request.QueryString("EmployeeID")) Is Nothing) Then EmployeeID = Convert.ToInt32(context.Request.QueryString("EmployeeID"))
Else Throw New ArgumentException("No parameter specified") End If
Dim imageData() As Byte = {}
' get the image data from the database using the employeeId Querystring context.Response.ContentType = "image/jpeg"
context.Response.BinaryWrite(imageData)
一切工作fine.Only的imageData
長度爲0,因此該圖像是無法顯示。
@Sean:其elsewhr ..這裏的查詢字符串正確地採取通過僱員...
繼承人的數據庫訪問代碼:
Public Sub bind()
Dim ds1 As New DataSet()
Dim con As New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString").ToString)
con.Open()
Dim query As String = "select * from EmployeeTable"
Dim cmd As New SqlCommand()
Dim da1 As New SqlDataAdapter(query, con)
da1.Fill(ds1, "EmployeeTable")
GridView1.DataSource = ds1.Tables("EmployeeTable")
GridView1.DataBind()
con.Close()
End Sub
這裏沒有代碼數據庫的訪問。 ..你填充字節數組的方式肯定有問題,否則它不會有數據。 – Sean 2013-03-05 11:46:25
its elsewhr ..這裏查詢字符串正確接受employeeid傳遞... 繼承人的數據庫訪問代碼: – adityawho 2013-03-05 11:52:16
好了,所以實際上並沒有將任何數據放入'imageData'變量。你在數據庫中存儲圖像數據的數據類型是什麼? – Sean 2013-03-05 12:01:55