B
Blasting Cap
I would like to try to see if an image uploaded to a SQL database is
over a specific size, and if so, to resize it when it is displayed. The
following is in the Page_load event.
Dim strImageID As String = "10" 'Request the value of ImageID
Dim data As New data
Dim sqlConnection As New SqlConnection(data.connectionString)
'Write your SQL connection here
Dim sqlCom As New SqlCommand("Select Data, Type From
tblTestImageStorage Where (ID='" & strImageID & "')", sqlConnection)
Dim sqlDataReader As SqlDataReader
sqlConnection.Open() 'Open Sqlconnection
sqlDataReader = sqlCom.ExecuteReader 'Execute the SQL command
While sqlDataReader.Read
Response.BinaryWrite(sqlDataReader.Item("Data")) 'Writing
the Image retrieved from the database
Response.ContentType = sqlDataReader.Item("Type") 'Setting
the type of the retrieved image
End While
sqlConnection.Close() 'Close Sqlconnection
How can I resize it, checking to make sure that if it's 3000x2000 I want
to resize to 800x600?
Nothing I've tried has worked. Trying to use the system.drawing.image
(an article from Rolla) gives me an invalid cast.
Any help appreciated.
BC
over a specific size, and if so, to resize it when it is displayed. The
following is in the Page_load event.
Dim strImageID As String = "10" 'Request the value of ImageID
Dim data As New data
Dim sqlConnection As New SqlConnection(data.connectionString)
'Write your SQL connection here
Dim sqlCom As New SqlCommand("Select Data, Type From
tblTestImageStorage Where (ID='" & strImageID & "')", sqlConnection)
Dim sqlDataReader As SqlDataReader
sqlConnection.Open() 'Open Sqlconnection
sqlDataReader = sqlCom.ExecuteReader 'Execute the SQL command
While sqlDataReader.Read
Response.BinaryWrite(sqlDataReader.Item("Data")) 'Writing
the Image retrieved from the database
Response.ContentType = sqlDataReader.Item("Type") 'Setting
the type of the retrieved image
End While
sqlConnection.Close() 'Close Sqlconnection
How can I resize it, checking to make sure that if it's 3000x2000 I want
to resize to 800x600?
Nothing I've tried has worked. Trying to use the system.drawing.image
(an article from Rolla) gives me an invalid cast.
Any help appreciated.
BC