If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Avoid Errors Procedure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #16 (permalink)  
Old 09-14-11, 21:10
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Can you publish you code as it stands now?
Reply With Quote
  #17 (permalink)  
Old 09-15-11, 03:10
macduff macduff is offline
Registered User
 
Join Date: Aug 2011
Posts: 11
Avoid Errors Procedure

Sure, here it is...
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
table.tool  {
    border:1px;
	border-style:solid;
	border-color:#0000ff;
	}
table.tool tr td {
    border:0px;
	border-style:solid;
	border-color:green;
	}
table.tool td  {
    padding:10px;
    font-family:arial;
	font-size:8pt;
	color:#0000ff;
	}
</style>
<%
call getCatItem(1)
call getCatItem(2)
call getCatItem(3)
call getCatItem(4)

sub getCatItem(catId)
    DIM objConn
    Set objConn = Server.CreateObject("ADODB.Connection")
    MdbFilePath = Server.MapPath("data/bling.mdb")
    objConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & MdbFilePath & ";"
 
    DIM mySQL
    mySQL = "SELECT caption, piece, price, image FROM goodies WHERE catnum = " & catID 

    DIM objRS
	Set objRS = Server.CreateObject("ADODB.Recordset")
	
	objRS.Open mySQL, objConn


response.write("<table class='tool' width='200px'>")

response.write("<tr><td colspan='2'>" & "<img src='")
response.write objRS("image")
response.write("'>" & "</td></tr>")

response.write("<tr><td colspan='2'>")
response.write objRS("caption")
response.write("</td></tr>")

response.write("<tr><td style='text-align:left;'>")
response.write objRS("piece")
response.write("</td><td style='text-align:right;'>" & "&pound;")
response.write objRS("price")
response.write("</td></tr>")

response.write("</table>")
end sub
%>
</head>

<body>
<% call getCatItem(2)%>
</body>

</html>
<%
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
%>
Thankyou Rokslide
Reply With Quote
  #18 (permalink)  
Old 09-19-11, 16:49
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
sorry for the delay, missed the reply message...

try this instead...
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
table.tool  {
    border:1px;
	border-style:solid;
	border-color:#0000ff;
	}
table.tool tr td {
    border:0px;
	border-style:solid;
	border-color:green;
	}
table.tool td  {
    padding:10px;
    font-family:arial;
	font-size:8pt;
	color:#0000ff;
	}
</style>
<%

%>
</head>

<body>
<%
getCatItem(1)
getCatItem(2)
getCatItem(3)
getCatItem(4)
%>
</body>

</html>
<%
sub getCatItem(catId)
    DIM objConn
    Set objConn = Server.CreateObject("ADODB.Connection")
    MdbFilePath = Server.MapPath("data/bling.mdb")
    objConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & MdbFilePath & ";"
 
    DIM mySQL
    mySQL = "SELECT caption, piece, price, image FROM goodies WHERE catnum = " & catID 

    DIM objRS
    Set objRS = Server.CreateObject("ADODB.Recordset")
	
    objRS.Open mySQL, objConn

    if(not(objRS.EOF)) then
        response.write("<table class='tool' width='200px'>")

        response.write("<tr><td colspan='2'>" & "<img src='")
        response.write objRS("image")
        response.write("'>" & "</td></tr>")

        response.write("<tr><td colspan='2'>")
        response.write objRS("caption")
        response.write("</td></tr>")

        response.write("<tr><td style='text-align:left;'>")
        response.write objRS("piece")
        response.write("</td><td style='text-align:right;'>" & "&pound;")
        response.write objRS("price")
        response.write("</td></tr>")

        response.write("</table>")
    end if
    objRS.Close
    Set objRS = Nothing
    objConn.Close
    Set objConn = Nothing
end sub
%>
Reply With Quote
  #19 (permalink)  
Old 09-20-11, 18:08
macduff macduff is offline
Registered User
 
Join Date: Aug 2011
Posts: 11
I looked into the server error logs and found it says 'Too few parameters' which I think points to a mismatch with the mdb. I'll check it out, but thanks for posting the update.
Reply With Quote
  #20 (permalink)  
Old 09-21-11, 16:58
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Can't rememeber if ASP classic is case sensitive but it might be. Have a look at the name of the paramter for the function compared to what is being concatenated.

One if catId, the other is catID.

Make them both the same.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On