I am pretty new to this myself, but I can tell you how I pulled pictures from a Access database. I didn't acttually put the pictures in the database I put the file path in instead and then I pulled from the database using the img tag in html. Here is the asp cod I used:
<%
Option Explicit
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adCmdText = &H0001
Dim CONN_STRING
CONN_STRING = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("d60.mdb")
Dim iPageSize
Dim iPageCount
Dim iPageCurrent
Dim strOrderBy
Dim strSQL
Dim objPagingConn
Dim objPagingRS
Dim iRecordsShown
Dim iFieldCount
Dim iRecordCount
Dim LoopRecordCount
Dim pageNum
Dim counter
Dim markShowPage
Dim I, J
iPageSize = 10
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If
strSQL = "SELECT tblgeneral.dir, tblgeneral.fileBase FROM [tblgeneral] ORDER BY tblgeneral.dateTaken"
Set objPagingConn = Server.CreateObject("ADODB.Connection")
objPagingConn.Open CONN_STRING
Set objPagingRS = Server.CreateObject("ADODB.Recordset")
objPagingRS.PageSize = iPageSize
objPagingRS.CacheSize = iPageSize
objPagingRS.Open strSQL, objPagingConn, adOpenStatic, adLockReadOnly, adCmdText
iPageCount = objPagingRS.PageCount
iFieldCount = objPagingRS.Fields.Count
iRecordCount = objPagingRS.RecordCount
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1
If iPageCount = 0 Then
Response.Write "No records found!"
Else
objPagingRS.AbsolutePage = iPageCurrent
Dim arrDBData
ReDim arrDBData(iFieldCount, iRecordCount)
LoopRecordCount = 0
'arrDBData = objPagingRS.GetRows()
Do While LoopRecordCount < iPageSize And Not objPagingRS.EOF
For I = 0 To objPagingRS.Fields.Count - 1
arrDBData(I, LoopRecordCount) = objPagingRS.Fields(I)
Next
LoopRecordCount = LoopRecordCount + 1
objPagingRS.MoveNext
Loop
objPagingRS.Close
Set objPagingRS = Nothing
objPagingConn.Close
Set objPagingConn = Nothing
End If
iRecordCount = iRecordCount - 1
iFieldCount = iFieldCount - 1
LoopRecordCount = LoopRecordCount - 1
pageNum = Round(iRecordCount/iPageSize)
If pageNum < (iRecordCount/iPageSize) Then pageNum = pageNum + 1
response.write looprecordcount
Response.Write "<form action=d60allPage.asp?page= method=get>"
Response.Write "<select name=page>"
For counter = 1 To pageNum
if counter=iPageCurrent then
Response.Write "<option value=" & counter & ">"
Response.Write " <span class=activepage> "
Response.Write counter
Response.Write " </span>"
markShowPage=1
Response.Write "</option>"
else
Response.Write "<option value=" & counter & ">"
Response.Write " <a onclick=exitoff() href=d60allPage.asp?page="
Response.Write counter
Response.Write " class=listingLink>"
Response.Write counter
Response.Write "</a>"
Response.Write "</option>"
end if
Next
Response.Write "</select>"
Response.Write " "
Response.Write "<input type=submit value=GotoPage>"
Response.Write "</form>"
Response.Write "</b>"
Response.Write "<b>"
Response.Write "<a href=d60allPage.asp?page="
If iPageCurrent = 1 Then
Response.Write pageNum
else
Response.Write iPageCurrent-1
end if
Response.Write " class=listingLink>Back</a> "
Response.Write "<a href=d60allPage.asp?page="
If iPageCurrent = pageNum Then
Response.Write "1"
else
Response.Write iPageCurrent+1
end if
Response.Write " class=listingLink>Next</a>"
Response.Write " & nbsp<b>Picture count = " & iRecordCount
Response.Write " & nbspPage: " & iPageCurrent & " of " & iPageCount
%>
<p>
<table border="1">
<%
For I = 0 To LoopRecordCount
For J = 0 To ifieldCount
Response.Write "<a target=_blank href=" & arrDBData(J, I) & "><img src=" & arrDBData(J, I) & " alt=" & arrDBData(J, I) & " height=133 width=200></img></a>"
Next ' J
Next ' I
%>
As you can see I am quite new to this. this allows you to page through your pictures. you can of course add query.
there is also an easy way of adding the file path of your pictures to the database. I use MSDOS window to display the file path. dir /a /b /s this is the command I use. and then I cut and paste this into a text document and the import it into the database.
I hope this helps.
Jeff
|