Save the picture to fix the new law after flowing into the database

xiaoxiao2021-03-06  111

The image type in SQL Server is image, then save it to the database via the DataSet, read the picture through the showimg.aspx file, that is, the picture is displayed, the code is as follows: DIM image as byte () = IssuequestionRow.questionImage '/ Convert to support storage The area is the flow of memory DIM MEMSTREAM AS New System.io.MemoryStream (Image) '/ Defines and instantiate Bitmap Object DIM BM AS New Bitmap (MemStream)' / Output or Download according to different conditions; response.clear () ' / If the request string specifies the download, download the file; '/ otherwise, it is displayed in the browser. If Request.QueryString ("Download") = "1" THEN Response.buffer = true response.contenttype = "Application / Oct-stream" '/ download the output file name ok.jpg as an example, you can actually depend Dynamic decision. Response.addheader ("Content-Disposition", "Attachment; FileName = OK.jpg") ELSE

Response.contentType = "image / jpg" end if Response.binarywrite (image)

Response.end () then adds to fix the display position, size, etc. of the picture. Of course, you can also get different pictures through different parameters of a page, as follows: showimg.aspx file: public QuestionID AS String Public Chapter (ByVal Sender As System.Object, Byval E AS System.EventArgs) Handles MyBase.Load 'is placed where the user code is initialized page If Not IsPostBack Then QuestionID = Request.QueryString ( "QID") ChapterID = Request.QueryString ( "ChapterID") Exercise = EXH.GetExercise (ChapterID) Dim dv As New DataView (Exercise.Ex_IssueQuestion) dv.RowFilter = "QuestionID = '" QuestionID "'" If dv.Count> 0 Then IssueQuestionRow = dv.Item (0) .Row Dim image As Byte () = IssueQuestionRow.QuestionImage '/ converter To support the storage area for memory DIM MEMSTREAM (Image) '/ define and instantiate Bitmap object DIM BM AS New Bitmap (MemStream)' / output or download according to different conditions; Response.BinaryWrite (image) end if end if End Sub only writes:

转载请注明原文地址:https://www.9cbs.com/read-102779.html

New Post(0)