There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
black screen blue screen boot bsod computer connection crash css dell display driver drivers email error firefox firefox 3 freeze game hard drive internet internet explorer itunes laptop malware monitor network networking nvidia outlook outlook 2003 outlook express partition password printer problem ram router security slow software sound startup trojan usb video virus vista windows windows xp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Help with ASP/vbscript code


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
coachdan32's Avatar
Computer Specs
Senior Member with 1,000 posts.
 
Join Date: Nov 2003
Location: Louisville, KY
23-Jul-2006, 01:06 AM #1
Help with ASP/vbscript code
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>
__________________
CoachDan
http://www.malehsbaseball.com

Gateway Pentium 4 3.0 GHz
200G Sata HD
800 FSB
512 DDR
DVD +-R/W
XP Home
coachdan32's Avatar
Computer Specs
Senior Member with 1,000 posts.
 
Join Date: Nov 2003
Location: Louisville, KY
23-Jul-2006, 06:51 PM #2
bump
Rockn's Avatar
Computer Specs
Distinguished Member with 17,888 posts.
 
Join Date: Jul 2001
Location: Mexico of the North, MN
Experience: Disenfranchised American Male
23-Jul-2006, 07:51 PM #3
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?
coachdan32's Avatar
Computer Specs
Senior Member with 1,000 posts.
 
Join Date: Nov 2003
Location: Louisville, KY
23-Jul-2006, 08:32 PM #4
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.
__________________
CoachDan
http://www.malehsbaseball.com

Gateway Pentium 4 3.0 GHz
200G Sata HD
800 FSB
512 DDR
DVD +-R/W
XP Home
Rockn's Avatar
Computer Specs
Distinguished Member with 17,888 posts.
 
Join Date: Jul 2001
Location: Mexico of the North, MN
Experience: Disenfranchised American Male
23-Jul-2006, 10:16 PM #5
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?
__________________
**Disclaimer** Anything below this line ^ is part of my signature for those that may be confused

Sadly, there are no integers on this scale, so your gangly adolescent attempt to be clever has proved futile....Dieter

I have the right "NOT" to be tolerant of others because they are different, weird, or tick me off.....Parody of Andy Rooney

There are no stupid questions, but there are a LOT of inquisitive idiots.
coachdan32's Avatar
Computer Specs
Senior Member with 1,000 posts.
 
Join Date: Nov 2003
Location: Louisville, KY
24-Jul-2006, 10:03 AM #6
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.
__________________
CoachDan
http://www.malehsbaseball.com

Gateway Pentium 4 3.0 GHz
200G Sata HD
800 FSB
512 DDR
DVD +-R/W
XP Home
coachdan32's Avatar
Computer Specs
Senior Member with 1,000 posts.
 
Join Date: Nov 2003
Location: Louisville, KY
24-Jul-2006, 05:29 PM #7
Here is the DB.
Attached Files
File Type: zip DB.zip (33.0 KB, 1 views)
Rockn's Avatar
Computer Specs
Distinguished Member with 17,888 posts.
 
Join Date: Jul 2001
Location: Mexico of the North, MN
Experience: Disenfranchised American Male
24-Jul-2006, 11:11 PM #8
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
File Type: zip files.zip (31.0 KB, 7 views)
__________________
**Disclaimer** Anything below this line ^ is part of my signature for those that may be confused

Sadly, there are no integers on this scale, so your gangly adolescent attempt to be clever has proved futile....Dieter

I have the right "NOT" to be tolerant of others because they are different, weird, or tick me off.....Parody of Andy Rooney

There are no stupid questions, but there are a LOT of inquisitive idiots.
coachdan32's Avatar
Computer Specs
Senior Member with 1,000 posts.
 
Join Date: Nov 2003
Location: Louisville, KY
25-Jul-2006, 11:08 AM #9
I will give it a try when I return home. Thanks for all the help! You are appreciated.
coachdan32's Avatar
Computer Specs
Senior Member with 1,000 posts.
 
Join Date: Nov 2003
Location: Louisville, KY
25-Jul-2006, 08:40 PM #10
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.
Rockn's Avatar
Computer Specs
Distinguished Member with 17,888 posts.
 
Join Date: Jul 2001
Location: Mexico of the North, MN
Experience: Disenfranchised American Male
25-Jul-2006, 09:00 PM #11
How were you gonna test ASP at home with XP Home? Anyway, you can install IIS on XP Home if you jump through a few hoops and then you could test locally.

http://www.15seconds.com/issue/020118.htm
coachdan32's Avatar
Computer Specs
Senior Member with 1,000 posts.
 
Join Date: Nov 2003
Location: Louisville, KY
26-Jul-2006, 02:31 PM #12
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?
Rockn's Avatar
Computer Specs
Distinguished Member with 17,888 posts.
 
Join Date: Jul 2001
Location: Mexico of the North, MN
Experience: Disenfranchised American Male
26-Jul-2006, 09:54 PM #13
IIS is better. PWS is really weak
coachdan32's Avatar
Computer Specs
Senior Member with 1,000 posts.
 
Join Date: Nov 2003
Location: Louisville, KY
27-Jul-2006, 03:45 PM #14
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.
__________________
CoachDan
http://www.malehsbaseball.com

Gateway Pentium 4 3.0 GHz
200G Sata HD
800 FSB
512 DDR
DVD +-R/W
XP Home
Rockn's Avatar
Computer Specs
Distinguished Member with 17,888 posts.
 
Join Date: Jul 2001
Location: Mexico of the North, MN
Experience: Disenfranchised American Male
27-Jul-2006, 08:32 PM #15
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.
__________________
**Disclaimer** Anything below this line ^ is part of my signature for those that may be confused

Sadly, there are no integers on this scale, so your gangly adolescent attempt to be clever has proved futile....Dieter

I have the right "NOT" to be tolerant of others because they are different, weird, or tick me off.....Parody of Andy Rooney

There are no stupid questions, but there are a LOT of inquisitive idiots.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:13 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.