Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 1st, 2007, 02:21 PM
Authorized User
 
Join Date: Feb 2007
Location: Winnipeg, Manitoba, Canada.
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default displaying Access database and query help

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">&nbsp;</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="rivcl@hotmail.com">
      <input type="hidden" name="receiver_email" value="rivcl@hotmail.com">
      <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>&nbsp;</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="rivcl@hotmail.com" />
          <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="rivcl@hotmail.com" />
          <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>&nbsp;</td>
      </tr>
</table>
<br />
<%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsgameused.MoveNext()
Wend
%>

<p>&nbsp;<A HREF="<%=MM_movePrev%>" class="style2">Previous</A> <A HREF="<%=MM_moveNext%>" class="style2">Next</A></p>

<p>&nbsp;</p>

</div></div>

<div id="footer">
  <p>&copy; 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.
__________________
Now is the only thing that\'s real.
Reply With Quote
  #2 (permalink)  
Old February 1st, 2007, 02:38 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

What is the value of this variable: dbPath

================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Reply With Quote
  #3 (permalink)  
Old February 1st, 2007, 02:51 PM
Authorized User
 
Join Date: Feb 2007
Location: Winnipeg, Manitoba, Canada.
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oops:
Sorry! It is defined on line 32.
dbPath="/db/HockeyCards.mdb"
This is the folder on my web server.
Should this come before the DRIVER=... line?
My guess is yes, but other tutorials showed it after, like I have.

Now is the only thing that's real.
Reply With Quote
  #4 (permalink)  
Old February 1st, 2007, 02:58 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Your Server.MapPath(dbPath) is mapping to nothing because you don't populate dbPath with a value until AFTER you build your connection string. So you are calling Server.MapPath(""), essentially.

================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Reply With Quote
  #5 (permalink)  
Old February 1st, 2007, 03:01 PM
Authorized User
 
Join Date: Feb 2007
Location: Winnipeg, Manitoba, Canada.
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok. From my understanding, you are saying that I either need to:
1. Spell out the db path.
2. put the dbPath="...." before the DRIVER"....."
Am I correct in this?

Now is the only thing that's real.
Reply With Quote
  #6 (permalink)  
Old February 1st, 2007, 03:09 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You are doing this:

hockeycards= "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=''& Server.MapPath(dbPath)"
Set hockeycards = Server.CreateObject("ADODB.Connection")
dbPath="/db/HockeyCards.mdb"

What you should be doing, in my opinion, is something like this:
Dim objConn
Dim sConnection
Dim dbPath

dbPath = "/db/HockeyCards.mdb"
sConnection = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=''& Server.MapPath(dbPath)"
Set objConn = Server.CreateObject("ADODB.Connection")

objConn.Open sConnection


================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Reply With Quote
  #7 (permalink)  
Old February 1st, 2007, 03:16 PM
Authorized User
 
Join Date: Feb 2007
Location: Winnipeg, Manitoba, Canada.
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yahoo! I think that may have fixed. it. My thanks to you. But......
Now it says there is a problem with my recordset. I am trying to link it to a query on my Access database. Here is my code:
Set rsgameused = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM" & tablename
rsgameused.CursorType = 0
rsgameused.CursorLocation = 2
rsgameused.LockType = 1
rsgameused.Open strSQL, sConnection

I don't even know what the CursorType, Location and LockType are. Dreamweaver just threw that in. What do I do? Must I manually create the recordset in the code?


Now is the only thing that's real.
Reply With Quote
  #8 (permalink)  
Old February 1st, 2007, 03:26 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

First about cursors and locks. This has to do with how your Recordset behaves when reading data from it and it is beyond the scope of this thread. There are many resources to read up on it, for a quick read go here:
http://www.js-examples.com/page/asp__cursor.html

And the reason your cannot work with your recordset, I am assuming, is because you are passing the Recordset object a connection string, not a connection object.

This
rsgameused.Open strSQL, sConnection

should be
rsgameused.Open strSQL, objConn

================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Reply With Quote
  #9 (permalink)  
Old February 1st, 2007, 03:41 PM
Authorized User
 
Join Date: Feb 2007
Location: Winnipeg, Manitoba, Canada.
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

dparsons,
Thank you for all your help. I'm not really a coder. I relied on Dreamweaver to do the coding, and now I see the error of my ways.
I'm still stuck. I took your advice above, but now I get this message:

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 49

Silly question. I do not have an "ActiveConnection" line of code anywhere here. Do I need one? I found some articles saying that is the cause of my trouble. I put one in but then my web browser said it was missing an object.
Any thoughts?

Now is the only thing that's real.
Reply With Quote
  #10 (permalink)  
Old February 1st, 2007, 03:52 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

It has been my expereience that you should only use ActiveConnection when you are using ADO Commands (to that end I have only ever had to use these when working with a stored procedure that has output parameters) Replace your code with this and tell me how it works. (Change the variable names to match yours of course)


Dim objConn
Dim sConnection
Dim dbPath
Dim rsgameused

dbPath = "/db/HockeyCards.mdb"
sConnection = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=''& Server.MapPath(dbPath)"
Set objConn = Server.CreateObject("ADODB.Connection")
Set rsgameused = Server.CreateObject("ADODB.RecordSet")
objConn.Open sConnection

strSQL = "SELECT * FROM" & tablename
rsgameused.Open strSQL, sConnection



================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript Access Database Query panuvin Javascript How-To 28 May 9th, 2008 01:53 PM
Displaying query from three tables slims07 .NET Framework 2.0 8 April 2nd, 2008 10:47 AM
Displaying data from access database tusharpat@gmail.com Classic ASP Basics 1 January 24th, 2006 06:35 PM
displaying the query lanita PHP How-To 6 August 23rd, 2004 11:11 PM
Database access from java, INSERT query problem nitusincog BOOK: Beginning Java 2 1 July 21st, 2003 10:26 AM



All times are GMT -4. The time now is 06:23 AM.


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