1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Help with ASP/vbscript code

Discussion in 'Web Design & Development' started by coachdan32, Jul 23, 2006.

Thread Status:
Not open for further replies.
Advertisement
  1. coachdan32

    coachdan32 Thread Starter

    Joined:
    Nov 13, 2003
    Messages:
    1,021
    Thanks to anyone who will take the time to help. I am trying to setup what should be a simple database driven website. I have very little experience with this type of project and the code below is my first attempt at setting this up. The code I have was taken from snippets I was able to find and could quite possibly be completely wrong for what I need. I set up a SystemDSN and the database is MS Access. I am not sure how I can test the code as the website does not exist yet and I am not sure of the exact path of the DB, since a host has not been identified yet. Any steps I can get closer to working code will be helpful.

    The table I am trying to setup needs to be able to grow with the number of records as they change and I would like to limit it to 3 columns per row. The Title should be listed with the FileName directly below it. The FileName will eventually be a .jpg that is found at the file path listed, but for the sake of getting started, I am settling on just the text of the FileName to start.

    <!--#include file="global.asa"-->
    <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>New Page 1</title>
    </head>

    <body bgcolor="#008080" link="#00FF00" vlink="#FFFF00" alink="#00FF00">

    'Create DB connection
    <%
    set cnn = server.createobject("ADODB.Connection")
    cnn.open "DRIVER = {Microsoft Access Driver (*.mdb)};DBQ=c:\My Webs\carlsweb.mdb"
    %>

    'Query Database for data
    <%
    SQL = SQL & " SELECT tblArt.Title, tblArt.Category, tblArt.FileName "

    SQL = SQL & " FROM tblArt "
    SQL = SQL & " WHERE tblArt.Category = "Animals"


    Set rs=Server.CreateObject("ADODB.RecordSet")
    rs.CursorLocation = adUseClient
    rs.CursorType = adOpenStatic
    rs.LockType = adLockOptimistic
    rs.Open SQL, MyDSN
    Set rs.ActiveConnection = Nothing

    If rs.RecordCount<>0 Then
    MAr = rs.GetRows()
    End If

    %>

    <div align="center">
    <table border="0" cellpadding="0" cellspacing="0" width="95%">
    <tr>
    <td width="100%" valign="top">
    <p align="left"><img border="0" src="http://forums.techguy.org/images/CarlHome.jpg" width="557" height="151"></td>
    </tr>
    <center>
    <tr>
    <td width="100%" valign="top">
    <p align="center">&nbsp;
    <p align="center"><font color="#FFFFFF" size="6"><b>Animals</b></font></td>
    </tr>
    </table>
    </center>
    </div>
    <div align="center">
    <center>
    <table border="0" cellpadding="0" cellspacing="0" width="95%" height="1510">
    <tr>
    <td width="18%" valign="top" rowspan="6" bgcolor="#D1D1D1" height="1502">
    <p align="center"><i><font size="5" color="#008080"><b><br>
    Gallery<br>
    </b></font><font color="#00FFFF" size="5"><br>
    <a href="animals.asp">
    <img border="0" src="http://forums.techguy.org/images/button11.jpg"></a><br>
    <a href="birds.asp">
    <img border="0" src="http://forums.techguy.org/images/button9.jpg"></a><br>
    <a href="landscapes.asp">
    <img border="0" src="http://forums.techguy.org/images/button2.jpg"></a><br>
    <a href="seascapes.asp">
    <img border="0" src="http://forums.techguy.org/images/button5.jpg"></a><br>
    <a href="miscellaneous.asp">
    <img border="0" src="http://forums.techguy.org/images/button23.jpg"></a><br>
    <a href="index.asp">
    <img border="0" src="http://forums.techguy.org/images/buttonB.jpg"></a></font></i></td>
    </tr>
    <tr>
    <td width="82%" valign="top" height="68" bgcolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
    <table width="100%" border="1">
    <tbody>
    </tbody>
    </table>
    <div align="center">
    <table border="1" cellpadding="0" cellspacing="0" width="95%">
    <tr>
    <td width="33%"><%Title%></td>
    </tr>
    <tr>
    <td width="33%"><%FileName%></td>
    </tr>
    </table>
    </div>
    <p align="center">&nbsp;</p>
    <p align="center">&nbsp;</td>
    </tr>
    <tr>
    <td width="82%" valign="middle" height="67">
    <p align="center"><b><font color="#00FF00" size="3"><u>Shipping &amp;
    Handling Rates For <i>Wildlife In Watercolor</i></u></font></b></td>
    </tr>
    <tr>
    <td width="82%" valign="top" height="116">
    <p align="center">&nbsp;</p>
    <p align="center"><b><font color="#FFFFFF"><a href="index.asp">Home</a> </font><font color="#FFFF00"> ~</font><font color="#FFFFFF">
    <a href="birds.asp"> Birds</a> </font><font color="#FFFF00"> ~</font><font color="#FFFFFF">
    </font><font color="#FFFF00"> Animals</font><font color="#FFFFFF"> </font><font color="#FFFF00"> ~</font><font color="#FFFFFF">
    <a href="landscapes.asp">
    Landscapes</a> </font><font color="#FFFF00"> ~</font><font color="#FFFFFF">
    <a href="seascapes.asp"> Seascapes</a> </font><font color="#FFFF00"> ~</font><font color="#FFFFFF">
    <a href="miscellaneous.asp"> Miscellaneous</a> </font><font color="#FFFF00"> ~</font><font color="#FFFFFF">&nbsp;<br>
    How to Order </font><font color="#FFFF00"> ~</font><font color="#FFFFFF"> Contact Us</font></b></p>
    <p align="center">&nbsp;</td>
    </tr>
    </center>
    <tr>
    <td width="82%" valign="top" height="97">
    <p align="center">&nbsp;</p>
    <p align="center"><font color="#FF0000"><b>Add Hit Counter Here</b></font></p>
    <p align="center">&nbsp;</td>
    </tr>
    <tr>
    <td width="82%" valign="top" height="59">
    <p align="center">&nbsp;</p>
    <p align="center"><font color="#FFFFFF"><b>This page was lasted edited
    on [Insert Date]</b></font></td>
    </tr>
    </table>
    </div>
    <div align="center">
    <center>
    <table border="1" cellpadding="0" cellspacing="0" width="95%">
    <tr>
    <td width="100%" bgcolor="#C0ABC0">
    <p align="center"><font color="#FFFFFF">© 2005 <i>Wildlife In
    Watercolor</i></font></td>
    </tr>
    </table>
    </center>
    </div>
    <%
    rs.Close
    Set rs=Nothing
    %>

    </body>

    </html>
     
  2. coachdan32

    coachdan32 Thread Starter

    Joined:
    Nov 13, 2003
    Messages:
    1,021
  3. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    Not sure what you are trying to do or where you want the database content to be displayed in the whole scheme of this page. If this is a static page why do you need a recordset unless the page content will be dynamic?
     
  4. coachdan32

    coachdan32 Thread Starter

    Joined:
    Nov 13, 2003
    Messages:
    1,021
    This for a friend that is an artist. He doesn't know anything about websites, but wants to be able to add new art to his website on his own. My intent is to have him upload his art images into his images folder and add the filename of the image to his DB and have it be added to the webpage that catalogs his art. The page I attached is for one of the categories of art he does. There are many different pieces of art in that category and I want to be able to display all of them (for that category) by having them pulled dynamically from the DB table. That way he can add a new piece of art to that category in the DB and have it added to this page without him having to know any HTML.
     
  5. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    This will not be a no brainer for your friend I am afraid. Unless you get an upload component and modify it to update the database it will be an administrative headache for him. THere are free upload components that can be easily modified. You should also make a table for the categories and have it linked via PK to the table the image locations will be held in. Do you have a sample of the database you will be using and image names?
     
  6. coachdan32

    coachdan32 Thread Starter

    Joined:
    Nov 13, 2003
    Messages:
    1,021
    Yes, I have the database ready. I will post a copy when I return home. I was hoping to find a way for him to upload his pictures as you mention, but wasn't sure how difficult it would be to come up with. I thought even if I couldn't, he could go to the site administration tool and upload the jpg. I know it shouldn't be too difficult to give him a page to input his new work and have it added to the database. As far as the file path for the artwork, I thought I could hardcode the path into the page where it would be displayed somehow - he would only have to know the name he gave the jpg and enter it on the add page. If the path was hardcoded in, the rest should happen behind the scenes hopefully.

    There are a lot of things I haven't figured out yet, as I am very new to DB driven content. I have to figure it out for him because his daughter was doing his site for him (static design) and she is in the hospital and may not survive to continue keeping it up for him. I would just take over for her, but time is a real issue for me most of the year as I administer the website in my signature for my son's HS baseball team and it keeps me quite busy 10 months out of the year. I appreciate your help and he will appreciate it even more, as this is his only means of income these days. He is getting too old to travel around to the art shows and market his talents.

    Does what I have look to be correct for the most part? I know that I need some kind of For/Next loop or something to loop through through the records until they have all been pulled, but I am not sure how/where to put this to ensure there are 3 pics with the titles above them in each row. I know there needs to be a counter or something for the row with titles and also one for the pics (FileName), but cannot visualize how the two would work together. Any help you can give would be appreciated and I will post the DB tonight when I get home.
     
  7. coachdan32

    coachdan32 Thread Starter

    Joined:
    Nov 13, 2003
    Messages:
    1,021
    Here is the DB. :)
     

    Attached Files:

    • DB.zip
      File size:
      33 KB
      Views:
      3
  8. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    Don't use lookups for table fields, just use the values and join them with the same name. For instance, in the Art table create a categoryNo field set to number so it corresponds to your category table. You can still do joins in your SQL statements in your vb script. You also don't need to put the URL encoding into the file names in the tables.

    Unzip all of these files to the root of your web site and it should work.
     

    Attached Files:

  9. coachdan32

    coachdan32 Thread Starter

    Joined:
    Nov 13, 2003
    Messages:
    1,021
    I will give it a try when I return home. Thanks for all the help! You are appreciated.
     
  10. coachdan32

    coachdan32 Thread Starter

    Joined:
    Nov 13, 2003
    Messages:
    1,021
    It looks like what I want Rockn, but I'll have to find a server to test it on. I will get back probably on the weekend. I have to find a free site to test it with.
     
  11. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
  12. coachdan32

    coachdan32 Thread Starter

    Joined:
    Nov 13, 2003
    Messages:
    1,021
    I have an XP Pro machine as well. I have thought about installing IIS on it, but I don't know anything about it. Can you use PWS with XP?
     
  13. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    IIS is better. PWS is really weak
     
  14. coachdan32

    coachdan32 Thread Starter

    Joined:
    Nov 13, 2003
    Messages:
    1,021
    Do you have a link(s) on how to set it up and administrate it? I would love to use it if I can learn how. Even if you can recommend a good book on the topic. I have not been able to find anything that seems to cover the topic.
     
  15. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    IIS is easy to set up and administer. You can only have one site in XP, so you will have to disable the default web site. Install IIS from the Add/Remove windows components and we can go from there. ASP is one of the default server side languages and you can also run PHP and .Net if you are so inclined. Let me know when you get it installed.
     
  16. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/485550

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice