HELP!
Ok, so I designed my site with Dreamweaver MX 2004. This includes the connection to my Access database and creating recordsets through Dreamweaver. I knew that when I uploaded my site to my server (easycgi) that I would have to change a few things. For example, my connection string was linked to my C: database, not the one uploaded to the server. I thought it would just be a matter of changing the location in the string. Not true!
I have tried making the code work, but I am stuck. What I am trying to do is establish a DSNless connection to my database on the server, and have it display a particular query from the database. I thought I had it, but I receive the following error:
ADODB.Recordset error '800a0e7d'
The connection cannot be used to perform this operation. It is either closed or invalid in this context.
/gameused.asp, line 45
I will now post the code below. I really hope that someone can help me! The area of the said query begins around line 26. Sorry the lines are not numbered! Easycgi says they do not provide customer service for coding, so I'm stuck!
Thanks in advance for anyone who can help!!!!!!
<%@LANGUAGE="VBSCRIPT"%>
<%
' *** Logout the current user.
MM_Logout = CStr(Request.ServerVariables("URL")) & "?MM_Logoutnow=1"
If (CStr(Request("MM_Logoutnow")) = "1") Then
Session.Contents.Remove("MM_Username")
Session.Contents.Remove("MM_UserAuthorization")
MM_logoutRedirectPage = "index.asp"
' redirect with URL parameters (remove the "MM_Logoutnow" query param).
if (MM_logoutRedirectPage = "") Then MM_logoutRedirectPage = CStr(Request.ServerVariables("URL"))
If (InStr(1, UC_redirectPage, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_newQS = "?"
For Each Item In Request.QueryString
If (Item <> "MM_Logoutnow") Then
If (Len(MM_newQS) > 1) Then MM_newQS = MM_newQS & "&"
MM_newQS = MM_newQS & Item & "=" & Server.URLencode(Request.QueryString(Item))
End If
Next
if (Len(MM_newQS) > 1) Then MM_logoutRedirectPage = MM_logoutRedirectPage & MM_newQS
End If
Response.Redirect(MM_logoutRedirectPage)
End If
%>
<%
' deleted include file to connections.asp %>
<%
Dim hockeycards, rsgameused, strSQL, tableName
hockeycards= "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=''& Server.MapPath(dbPath)"
Set hockeycards = Server.CreateObject("ADODB.Connection")
dbPath="/db/HockeyCards.mdb"
tableName= "bigcardtable"
' Check error
Err.clear
if(Err<>0) then
Response.Write "Connected to database: " & dbPath
end if
Set rsgameused = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM" & tablename
rsgameused.CursorType = 0
rsgameused.CursorLocation = 2
rsgameused.LockType = 1
rsgameused.Open strSQL, hockeycards
rsgameused_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = 20
Repeat1__index = 0
rsgameused_numRows = rsgameused_numRows + Repeat1__numRows
%>
<%
' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables
Dim rsgameused_total
Dim rsgameused_first
Dim rsgameused_last
' set the record count
rsgameused_total = rsgameused.RecordCount
' set the number of rows displayed on this page
If (rsgameused_numRows < 0) Then
rsgameused_numRows = rsgameused_total
Elseif (rsgameused_numRows = 0) Then
rsgameused_numRows = 1
End If
' set the first and last displayed record
rsgameused_first = 1
rsgameused_last = rsgameused_first + rsgameused_numRows - 1
' if we have the correct record count, check the other stats
If (rsgameused_total <> -1) Then
If (rsgameused_first > rsgameused_total) Then
rsgameused_first = rsgameused_total
End If
If (rsgameused_last > rsgameused_total) Then
rsgameused_last = rsgameused_total
End If
If (rsgameused_numRows > rsgameused_total) Then
rsgameused_numRows = rsgameused_total
End If
End If
%>
<%
' *** Recordset Stats: if we don't know the record count, manually count them
If (rsgameused_total = -1) Then
' count the total records by iterating through the recordset
rsgameused_total=0
While (Not rsgameused.EOF)
rsgameused_total = rsgameused_total + 1
rsgameused.MoveNext
Wend
' reset the cursor to the beginning
If (rsgameused.CursorType > 0) Then
rsgameused.MoveFirst
Else
rsgameused.Requery
End If
' set the number of rows displayed on this page
If (rsgameused_numRows < 0 Or rsgameused_numRows > rsgameused_total) Then
rsgameused_numRows = rsgameused_total
End If
' set the first and last displayed record
rsgameused_first = 1
rsgameused_last = rsgameused_first + rsgameused_numRows - 1
If (rsgameused_first > rsgameused_total) Then
rsgameused_first = rsgameused_total
End If
If (rsgameused_last > rsgameused_total) Then
rsgameused_last = rsgameused_total
End If
End If
%>
<%
Dim MM_paramName
%>
<%
' *** Move To Record and Go To Record: declare variables
Dim MM_rs
Dim MM_rsCount
Dim MM_size
Dim MM_uniqueCol
Dim MM_offset
Dim MM_atTotal
Dim MM_paramIsDefined
Dim MM_param
Dim MM_index
Set MM_rs = rsgameused
MM_rsCount = rsgameused_total
MM_size = rsgameused_numRows
MM_uniqueCol = ""
MM_paramName = ""
MM_offset = 0
MM_atTotal = false
MM_paramIsDefined = false
If (MM_paramName <> "") Then
MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")
End If
%>
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername=CStr(Request.Form("Uname"))
If MM_valUsername <> "" Then
MM_fldUserAuthorization="AccessLevel"
MM_redirectLoginSuccess="welcome.asp"
MM_redirectLoginFailed="sorry.asp"
MM_flag="ADODB.Recordset"
set MM_rsUser = Server.CreateObject(MM_flag)
MM_rsUser.ActiveConnection = hockeycards
MM_rsUser.Source = "SELECT Uname, Pass"
If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldUserAuthorization
MM_rsUser.Source = MM_rsUser.Source & " FROM CustomerList WHERE Uname='" & Replace(MM_valUsername,"'","''") &"' AND Pass='" & Replace(Request.Form("Pass"),"'","''") & "'"
MM_rsUser.CursorType = 0
MM_rsUser.CursorLocation = 2
MM_rsUser.LockType = 3
MM_rsUser.Open
If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
' username and password match - this is a valid user
Session("MM_Username") = MM_valUsername
If (MM_fldUserAuthorization <> "") Then
Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization ).Value)
Else
Session("MM_UserAuthorization") = ""
End If
if CStr(Request.QueryString("accessdenied")) <> "" And false Then
MM_redirectLoginSuccess = Request.QueryString("accessdenied")
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginFailed)
End If
%>
<%
' *** Move To Record: handle 'index' or 'offset' parameter
if (Not MM_paramIsDefined And MM_rsCount <> 0) then
' use index parameter if defined, otherwise use offset parameter
MM_param = Request.QueryString("index")
If (MM_param = "") Then
MM_param = Request.QueryString("offset")
End If
If (MM_param <> "") Then
MM_offset = Int(MM_param)
End If
' if we have a record count, check if we are past the end of the recordset
If (MM_rsCount <> -1) Then
If (MM_offset >= MM_rsCount Or MM_offset = -1) Then ' past end or move last
If ((MM_rsCount Mod MM_size) > 0) Then ' last page not a full repeat region
MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
Else
MM_offset = MM_rsCount - MM_size
End If
End If
End If
' move the cursor to the selected record
MM_index = 0
While ((Not MM_rs.EOF) And (MM_index < MM_offset Or MM_offset = -1))
MM_rs.MoveNext
MM_index = MM_index + 1
Wend
If (MM_rs.EOF) Then
MM_offset = MM_index ' set MM_offset to the last possible record
End If
End If
%>
<%
' *** Move To Record: if we dont know the record count, check the display range
If (MM_rsCount = -1) Then
' walk to the end of the display range for this page
MM_index = MM_offset
While (Not MM_rs.EOF And (MM_size < 0 Or MM_index < MM_offset + MM_size))
MM_rs.MoveNext
MM_index = MM_index + 1
Wend
' if we walked off the end of the recordset, set MM_rsCount and MM_size
If (MM_rs.EOF) Then
MM_rsCount = MM_index
If (MM_size < 0 Or MM_size > MM_rsCount) Then
MM_size = MM_rsCount
End If
End If
' if we walked off the end, set the offset based on page size
If (MM_rs.EOF And Not MM_paramIsDefined) Then
If (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) Then
If ((MM_rsCount Mod MM_size) > 0) Then
MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
Else
MM_offset = MM_rsCount - MM_size
End If
End If
End If
' reset the cursor to the beginning
If (MM_rs.CursorType > 0) Then
MM_rs.MoveFirst
Else
MM_rs.Requery
End If
' move the cursor to the selected record
MM_index = 0
While (Not MM_rs.EOF And MM_index < MM_offset)
MM_rs.MoveNext
MM_index = MM_index + 1
Wend
End If
%>
<%
' *** Move To Record: update recordset stats
' set the first and last displayed record
rsgameused_first = MM_offset + 1
rsgameused_last = MM_offset + MM_size
If (MM_rsCount <> -1) Then
If (rsgameused_first > MM_rsCount) Then
rsgameused_first = MM_rsCount
End If
If (rsgameused_last > MM_rsCount) Then
rsgameused_last = MM_rsCount
End If
End If
' set the boolean used by hide region to check if we are on the last record
MM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
Dim MM_keepNone
Dim MM_keepURL
Dim MM_keepForm
Dim MM_keepBoth
Dim MM_removeList
Dim MM_item
Dim MM_nextItem
' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then
MM_removeList = MM_removeList & "&" & MM_paramName & "="
End If
MM_keepURL=""
MM_keepForm=""
MM_keepBoth=""
MM_keepNone=""
' add the URL parameters to the MM_keepURL string
For Each MM_item In Request.QueryString
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item))
End If
Next
' add the Form variables to the MM_keepForm string
For Each MM_item In Request.Form
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item))
End If
Next
' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
If (MM_keepBoth <> "") Then
MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
End If
If (MM_keepURL <> "") Then
MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
End If
If (MM_keepForm <> "") Then
MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
End If
' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
If (firstItem <> "") Then
MM_joinChar = "&"
Else
MM_joinChar = ""
End If
End Function
%>
<%
' *** Move To Record: set the strings for the first, last, next, and previous links
Dim MM_keepMove
Dim MM_moveParam
Dim MM_moveFirst
Dim MM_moveLast
Dim MM_moveNext
Dim MM_movePrev
Dim MM_urlStr
Dim MM_paramList
Dim MM_paramIndex
Dim MM_nextParam
MM_keepMove = MM_keepBoth
MM_moveParam = "index"
' if the page has a repeated region, remove 'offset' from the maintained parameters
If (MM_size > 1) Then
MM_moveParam = "offset"
If (MM_keepMove <> "") Then
MM_paramList = Split(MM_keepMove, "&")
MM_keepMove = ""
For MM_paramIndex = 0 To UBound(MM_paramList)
MM_nextParam = Left(MM_paramList(MM_paramIndex), InStr(MM_paramList(MM_paramIndex),"=") - 1)
If (StrComp(MM_nextParam,MM_moveParam,1) <> 0) Then
MM_keepMove = MM_keepMove & "&" & MM_paramList(MM_paramIndex)
End If
Next
If (MM_keepMove <> "") Then
MM_keepMove = Right(MM_keepMove, Len(MM_keepMove) - 1)
End If
End If
End If
' set the strings for the move to links
If (MM_keepMove <> "") Then
MM_keepMove = Server.HTMLEncode(MM_keepMove) & "&"
End If
MM_urlStr = Request.ServerVariables("URL") & "?" & MM_keepMove & MM_moveParam & "="
MM_moveFirst = MM_urlStr & "0"
MM_moveLast = MM_urlStr & "-1"
MM_moveNext = MM_urlStr & CStr(MM_offset + MM_size)
If (MM_offset - MM_size < 0) Then
MM_movePrev = MM_urlStr & "0"
Else
MM_movePrev = MM_urlStr & CStr(MM_offset - MM_size)
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Centre Ice Hockey Game Used Cards!!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="imagetoolbar" content="false" />
<link href="foto.css" rel="stylesheet" type="text/css" media="all" />
<style type="text/css">
<!--
.style1 {color: #0033CC}
.style2 {font-size: 16px}
-->
</style>
</head>
<body >
<div id="Layer1" style="position:absolute; left:301px; top:6px; width:389px; height:109px; z-index:1">
<form name="form2" id="form2" method="POST" action="<%=MM_LoginAction%>">
<table width="70%" border="0">
<tr>
<td><span class="style1">Username:</span></td>
<td><input name="Uname" type="text" class="style1" id="Uname" /></td>
</tr>
<tr>
<td><span class="style1">Password:</span></td>
<td><input name="Pass" type="password" class="style1" id="Pass" />
<a href="<%= MM_Logout %>">Log out</a></td>
</tr>
<tr>
<td><input name="Submit" type="submit" class="style1" value="Submit" /></td>
<td><span class="style1">Not a Member? <a href="register.asp">Register here!</a> </span></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
</form></div>
<div id="Layer2" style="position:absolute; left:636px; top:3px; width:96px; height:75px; z-index:2">
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<p>
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="display" value="1">
<input type="hidden" name="bn" value="webassist.dreamweaver.4_0_3">
<input type="hidden" name="business" value="
[email protected]">
<input type="hidden" name="receiver_email" value="
[email protected]">
<input type="hidden" name="mrb" value="R-3WH47588B4505740X">
<input type="hidden" name="pal" value="ANNSXSLJLYR2A">
<input type="image" name="submit" src="http://images.paypal.com/images/x-click-but27.gif" border="0" alt="Make payments with PayPal - it's fast, free and secure!">
</p>
<p> </p>
</form>
</div>
<div id="skipnav"><a href="#content" tabindex="1" title="Skip Navigation" accesskey="2">Skip Navigation</a></div>
<div id="logo1"><img src="i/logo1.gif" width="262" height="92" /></div>
<div id="logo2"><img src="i/logo2.gif" width="204" height="89" /></div>
<div id="nav">
<h3>Navigation</h3>
[list]
<li id="current"><a href="index.asp" tabindex="2" title="link title">Home</a></li>
<li><a href="rookies.asp" tabindex="3" title="link title">Rookie Cards</a></li>
<li><a href="gameused.asp" tabindex="4" title="link title">Game Used</a></li>
<li><a href="autographs.asp" tabindex="5" title="link title">Autographs</a></li>
<li><a href="inserts.asp" tabindex="13" title="link title">Inserts/Parallels</a></li>
<li><a href="graded.asp" tabindex="6" title="link title">Graded Cards</a></li>
<li><a href="singles.asp" tabindex="7" title="link title">Singles</a></li>
<li><a href="sets.asp" tabindex="8" title="link title">Sets</a></li>
<li><a href="specialty.asp" tabindex="9" title="link title">Specialty</a></li>
</ul>
<h3>Search</h3>
<form name="form1" id="form1" method="post" action="searchresults.asp">
<div align="center">
<input name="txtSearch" type="text" id="txtSearch" />
<br />
<br />
<input name="btnSearch" type="submit" id="btnSearch" value="Search" />
</div>
</form>[list]
<li><a href="shipping.asp" tabindex="10" title="link title">Ordering Info</a></li>
<li><a href="aboutus.asp" tabindex="11" title="link title">About Us</a></li>
<li><a href="contact.asp" tabindex="12" title="link title">Contact</a></li>
<li><a href="links.asp" tabindex="13" title="link title">Links</a></li>
</ul>
</div>
<div id="wrapper">
<div id="content">
<h1 class="style1">Game Used Cards </h1>
<p class="style1">We have a great selection of game used cards. Be it jerseys, sticks, patches, we have a bit of everything.<br />
We currently have <%=(rsgameused_total)%> game used cards for you to look at. </p>
<%
While ((Repeat1__numRows <> 0) AND (NOT rsgameused.EOF))
%>
<table width="97%" border="1">
<tr>
<td rowspan="6"><img src="<%=(rsgameused.Fields.Item("ImagePath").Value )%>" alt="Picture of <%=(rsgameused.Fields.Item("PlayerName").Value)% >, <%=(rsgameused.Fields.Item("CardDescription").Valu e)%>"/></td>
<td width="25%"><span class="style1">Player Name:</span></td>
<td width="55%" class="style1"><%=(rsgameused.Fields.Item("PlayerN ame").Value)%></td>
</tr>
<tr>
<td class="style1">Card Description: </td>
<td class="style1"><%=(rsgameused.Fields.Item("CardDes cription").Value)%></td>
</tr>
<tr>
<td class="style1">Serial Number: </td>
<td class="style1"><%=(rsgameused.Fields.Item("SerialN umber").Value)%></td>
</tr>
<tr>
<td class="style1">Price:</td>
<td class="style1">$<%=(rsgameused.Fields.Item("Price" ).Value)%></td>
</tr>
<tr>
<td class="style1">Quantity Available:</td>
<td class="style1"><%=(rsgameused.Fields.Item("Quantit y").Value)%></td>
</tr>
<tr>
<td colspan="2"><form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="bn" value="webassist.dreamweaver.4_0_3" />
<input type="hidden" name="business" value="
[email protected]" />
<input type="hidden" name="item_name" value="<%=rsgameused("PlayerName")%>, <%=rsgameused("CardDescription")%>" /><br />
<input type="hidden" name="amount" value="<%=rsgameused("Price")%>" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="return" value="http://www.centreicehockey.com/success.asp" />
<input type="hidden" name="cancel_return" value="http://www.centreicehockey.com/failed.asp" />
<input type="hidden" name="receiver_email" value="
[email protected]" />
<input type="hidden" name="mrb" value="R-3WH47588B4505740X" />
<input type="hidden" name="pal" value="ANNSXSLJLYR2A" />
<input type="hidden" name="no_shipping" value="0" />
<input type="hidden" name="no_note" value="0" />
<input type="image" name="submit" src="http://images.paypal.com/images/sc-but-03.gif" border="0" alt="Make payments with PayPal - it's fast, free and secure!" />
</form> </td>
</tr>
</table>
<br />
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsgameused.MoveNext()
Wend
%>
<p> <A HREF="<%=MM_movePrev%>" class="style2">Previous</A> <A HREF="<%=MM_moveNext%>" class="style2">Next</A></p>
<p> </p>
</div></div>
<div id="footer">
<p>© 2005 Clint Rivest. Thanks to Gordonmac for the template! </p>
</div>
</body>
</html>
<%
rsgameused.Close()
Set rsgameused = Nothing
%>Now is the only thing that's real.