A
Auddog
First, let me thank you for any help that you mgiht be able to offer.
I have a sql query that I'm trying to get the variable for and I keep
getting the same error:
Item cannot be found in the collection corresponding to the requested name
or ordinal.
Here is my database layout:
Database layout (2 tables)
Table 1
Projects (Table name)
id (primary key)
projectid
projectname
Table 2
ShopLog (Table Name)
id (primary key)
fk_id (foreign key to match projects - id)
sd_title
receivedfrom
Here is my query:
strSQL = "SELECT ShopLog.id, ShopLog.fk_projectid, ShopLog.sd_title,
ShopLog.receivedfrom, Projects.id, Projects.projectname FROM ShopLog,
Projects WHERE ShopLog.fk_projectid="& pid &" and Projects.id = "& pid &""
I'm just not sure how to set the variables for this type of sql call.
Here is my page code:
<%@ language="vbscript" %>
<% Option Explicit %>
<% Response.Buffer=True %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<!-- #include file="dbConn.asp" -->
<!-- #include file="adovbs.inc" -->
<%
Dim adoDB, adoRS, strSQL, iRecordCount, pid, projectname
'id variable passed from previous page set to new variable pid
pid = Request.QueryString("id")
' Create the Database Object, and connect to it
Set adoDB = Server.CreateObject("ADODB.Connection")
adoDB.Open strConnection
' Create the Recordset Object
Set adoRS = Server.CreateObject("ADODB.RecordSet")
' Create a SQL string, to open the recordset
strSQL = "SELECT ShopLog.id, ShopLog.fk_projectid, ShopLog.sd_title,
ShopLog.receivedfrom, Projects.id, Projects.projectname FROM ShopLog,
Projects WHERE ShopLog.fk_projectid="& pid &" and Projects.id = "& pid &""
adoRS.Open strSQL, adoDB, adOpenDynamic, adLockReadOnly, adCmdText
%>
<head>
<title>Shop Log</title>
</head>
<body>
<div align="center">
<table border=1>
<tr>
<td colspan=4><% Response.Write adoRS("projectname") %></td>
</tr>
<tr>
<td>Shop Log Title</td>
<td>From</td>
<td>CheckIn Date</td>
<td>Returned</td>
</tr>
<tr>
<%
'iRecordCount = 0
DO WHILE NOT adoRS.EOF
'IF iRecordCount Mod 2 = 0 THEN
%>
<td><a href="edit_project.asp?id=<% = adoRS("id") %>"><% Response.Write
adoRS("sd_title") %></a></td>
<td><% Response.Write adoRS("receivedfrom") %></td>
<td><% Response.Write adoRS("checkindate") %></td>
<td><% Response.Write adoRS("returned") %></td>
</tr>
</tr>
<% adoRS.MoveNext
Loop
' Tidy up afterwards
adoRS.Close
Set adoRS = Nothing
adoDB.Close
Set adoDB = Nothing
%>
</tr>
</table>
</div>
</body>
</html>
A
I have a sql query that I'm trying to get the variable for and I keep
getting the same error:
Item cannot be found in the collection corresponding to the requested name
or ordinal.
Here is my database layout:
Database layout (2 tables)
Table 1
Projects (Table name)
id (primary key)
projectid
projectname
Table 2
ShopLog (Table Name)
id (primary key)
fk_id (foreign key to match projects - id)
sd_title
receivedfrom
Here is my query:
strSQL = "SELECT ShopLog.id, ShopLog.fk_projectid, ShopLog.sd_title,
ShopLog.receivedfrom, Projects.id, Projects.projectname FROM ShopLog,
Projects WHERE ShopLog.fk_projectid="& pid &" and Projects.id = "& pid &""
I'm just not sure how to set the variables for this type of sql call.
Here is my page code:
<%@ language="vbscript" %>
<% Option Explicit %>
<% Response.Buffer=True %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<!-- #include file="dbConn.asp" -->
<!-- #include file="adovbs.inc" -->
<%
Dim adoDB, adoRS, strSQL, iRecordCount, pid, projectname
'id variable passed from previous page set to new variable pid
pid = Request.QueryString("id")
' Create the Database Object, and connect to it
Set adoDB = Server.CreateObject("ADODB.Connection")
adoDB.Open strConnection
' Create the Recordset Object
Set adoRS = Server.CreateObject("ADODB.RecordSet")
' Create a SQL string, to open the recordset
strSQL = "SELECT ShopLog.id, ShopLog.fk_projectid, ShopLog.sd_title,
ShopLog.receivedfrom, Projects.id, Projects.projectname FROM ShopLog,
Projects WHERE ShopLog.fk_projectid="& pid &" and Projects.id = "& pid &""
adoRS.Open strSQL, adoDB, adOpenDynamic, adLockReadOnly, adCmdText
%>
<head>
<title>Shop Log</title>
</head>
<body>
<div align="center">
<table border=1>
<tr>
<td colspan=4><% Response.Write adoRS("projectname") %></td>
</tr>
<tr>
<td>Shop Log Title</td>
<td>From</td>
<td>CheckIn Date</td>
<td>Returned</td>
</tr>
<tr>
<%
'iRecordCount = 0
DO WHILE NOT adoRS.EOF
'IF iRecordCount Mod 2 = 0 THEN
%>
<td><a href="edit_project.asp?id=<% = adoRS("id") %>"><% Response.Write
adoRS("sd_title") %></a></td>
<td><% Response.Write adoRS("receivedfrom") %></td>
<td><% Response.Write adoRS("checkindate") %></td>
<td><% Response.Write adoRS("returned") %></td>
</tr>
</tr>
<% adoRS.MoveNext
Loop
' Tidy up afterwards
adoRS.Close
Set adoRS = Nothing
adoDB.Close
Set adoDB = Nothing
%>
</tr>
</table>
</div>
</body>
</html>
A