01.
Imports
System.Data
02.
Imports
System.Data.SqlClient
03.
04.
Partial
Class
ViewImg
05.
Inherits
System.Web.UI.Page
06.
07.
Dim
objConn
As
New
SqlConnection
08.
Dim
objCmd
As
SqlCommand
09.
Dim
strConnString, strSQL
As
String
10.
11.
Protected
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
12.
13.
strConnString =
"Server=localhost;Uid=sa;PASSWORD=;database=mydatabase;Max Pool Size=400;Connect Timeout=600;"
14.
objConn.ConnectionString = strConnString
15.
objConn.Open()
16.
17.
18.
Dim
dtAdapter
As
SqlDataAdapter
19.
Dim
dt
As
New
DataTable
20.
strSQL =
"SELECT * FROM files WHERE FilesID = @sFilesID "
21.
dtAdapter =
New
SqlDataAdapter(strSQL, objConn)
22.
objCmd = dtAdapter.SelectCommand
23.
objCmd.Parameters.Add(
"@sFilesID"
, SqlDbType.Int).Value = Request.QueryString(
"FilesID"
)
24.
dtAdapter.Fill(dt)
25.
26.
If
dt.Rows.Count > 0
Then
27.
Response.ContentType = dt.Rows(0)(
"FilesType"
).ToString()
28.
Response.BinaryWrite(dt.Rows(0)(
"FilesName"
))
29.
End
If
30.
31.
dt =
Nothing
32.
End
Sub
33.
34.
Protected
Sub
Page_Unload(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Unload
35.
objConn.Close()
36.
objConn =
Nothing
37.
End
Sub
38.
39.
End
Class