Wrox Programmer Forums
|
Access ASP Using ASP with Microsoft Access databases. For Access questions not specific to ASP, please use the Access forum. For more ASP forums, please see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 2nd, 2004, 06:43 AM
Registered User
 
Join Date: May 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Images

How can images from a access database be used on an asp page

 
Old September 7th, 2004, 10:24 AM
Registered User
 
Join Date: Jul 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jripke74
Default

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 "&nbsp;<span class=activepage>&nbsp;"
        Response.Write counter
        Response.Write "&nbsp;</span>"
        markShowPage=1
        Response.Write "</option>"
    else
        Response.Write "<option value=" & counter & ">"
        Response.Write "&nbsp;<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 "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
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>&nbsp;&nbsp;"
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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp<b>Picture count = " & iRecordCount
Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& 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

 
Old September 11th, 2004, 07:34 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

You can do a search on that here. I remember this was discussed here sometime back.

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
Load Images from and Save Images to a Database cyndie VB.NET 2 August 17th, 2008 06:42 AM
IMAGES OldCoder BOOK: Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages ISBN: 978-0-470-12448-2 3 November 20th, 2007 11:26 AM
Images OldCoder ASP.NET 2.0 Professional 0 November 11th, 2007 09:17 PM
IMAGES chmosiii CSS Cascading Style Sheets 6 November 8th, 2005 10:09 AM
Images rajanikrishna HTML Code Clinic 1 May 5th, 2004 10:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.