logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > ASP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 04-17-2008, 03:04 PM   #1
meichmann
 
Join Date: Apr 2008
Posts: 2
Unhappy Postback with a Dreamweaver database connection

Hello everyone!
I have a page made by Dreamweaver that automatically retrieves information from a database and displays it in a table. What I need to do is incorporate a postback function so people can search the results on that page to further drill down what they want to see.

I have tried multiple time to accomplish this with no success. If anyone knows how to do this, it would be greatly appreciated. I am including the code at the bottom of this post. I know it's long, but it might help in getting a solution.

Thank you very much in advance.

Matt


*Code Starts Here*
Code:
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../../../../Connections/ConnSolicitation.asp" -->
<%
Dim rsCategory
Dim rsCategory_numRows
 
Set rsCategory = Server.CreateObject("ADODB.Recordset")
rsCategory.ActiveConnection = MM_ConnSolicitation_STRING
rsCategory.Source = "SELECT * FROM dbo.Bids WHERE Active=1 AND DATEDIFF(day,OpeningDate,GetDate()) < 1 ORDER BY BidCategory, BidName, ExpirationDate"
rsCategory.CursorType = 0
rsCategory.CursorLocation = 2
rsCategory.LockType = 1
rsCategory.Open()
rsCategory_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = 10
Repeat1__index = 0
rsCategory_numRows = rsCategory_numRows + Repeat1__numRows
%>
<%
' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables
Dim rsCategory_total
Dim rsCategory_first
Dim rsCategory_last
' set the record count
rsCategory_total = rsCategory.RecordCount
' set the number of rows displayed on this page
If (rsCategory_numRows < 0) Then
rsCategory_numRows = rsCategory_total
Elseif (rsCategory_numRows = 0) Then
rsCategory_numRows = 1
End If
' set the first and last displayed record
rsCategory_first = 1
rsCategory_last = rsCategory_first + rsCategory_numRows - 1
' if we have the correct record count, check the other stats
If (rsCategory_total <> -1) Then
If (rsCategory_first > rsCategory_total) Then
rsCategory_first = rsCategory_total
End If
If (rsCategory_last > rsCategory_total) Then
rsCategory_last = rsCategory_total
End If
If (rsCategory_numRows > rsCategory_total) Then
rsCategory_numRows = rsCategory_total
End If
End If
%>
<%
' *** Recordset Stats: if we don't know the record count, manually count them
If (rsCategory_total = -1) Then
' count the total records by iterating through the recordset
rsCategory_total=0
While (Not rsCategory.EOF)
rsCategory_total = rsCategory_total + 1
rsCategory.MoveNext
Wend
' reset the cursor to the beginning
If (rsCategory.CursorType > 0) Then
rsCategory.MoveFirst
Else
rsCategory.Requery
End If
' set the number of rows displayed on this page
If (rsCategory_numRows < 0 Or rsCategory_numRows > rsCategory_total) Then
rsCategory_numRows = rsCategory_total
End If
' set the first and last displayed record
rsCategory_first = 1
rsCategory_last = rsCategory_first + rsCategory_numRows - 1
 
If (rsCategory_first > rsCategory_total) Then
rsCategory_first = rsCategory_total
End If
If (rsCategory_last > rsCategory_total) Then
rsCategory_last = rsCategory_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 = rsCategory
MM_rsCount = rsCategory_total
MM_size = rsCategory_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
%>
<%
' *** 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
rsCategory_first = MM_offset + 1
rsCategory_last = MM_offset + MM_size
If (MM_rsCount <> -1) Then
If (rsCategory_first > MM_rsCount) Then
rsCategory_first = MM_rsCount
End If
If (rsCategory_last > MM_rsCount) Then
rsCategory_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 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Burlington County Solicitations Site</title>
<style type="text/css">
<!--
.style2 {
font-size: small;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
color: #FF0000;
}
body {
background-color: #3366FF;
}
.style3 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: x-small;
}
.style7 {color: #000000}
.style9 {color: #0000FF; font-weight: bold; }
.style10 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: x-small; font-weight: bold; color: #0000FF; }
-->
</style>
<script type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
<body onload="MM_preloadImages('../images/date2.jpg','../images/awarded2.jpg','../images/awarddate2.jpg','../images/category2.jpg')">
<table width="753" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"><div align="center"><img src="../images/solicitations.jpg" width="753" height="175" /></div></td>
</tr>
<tr>
<td height="383" valign="top"><table width="100%" height="124" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" bgcolor="#996633"><a href="index.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image4','','../images/category2.jpg',1)"><img src="../images/category.jpg" alt="Formal Bids Sorted By Category" name="Image4" width="100" height="30" border="0" id="Image4" /></a><br />
<a href="../date/index.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image3','','../images/date2.jpg',1)"><br />
</a><a href="../date/index.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image3','','../images/date2.jpg',1)"><img src="../images/date.jpg" alt="Formal Bids Sorted by Date" name="Image3" width="100" height="30" border="0" id="Image3" /></a><br />
<br />
<a href="../award/index.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image5','','../images/awarded2.jpg',1)"><img src="../images/awarded.jpg" alt="Awarded Formal Bids" name="Image5" width="100" height="30" border="0" id="Image5" /></a><br />
<br />
<a href="../awarddate/index.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image7','','../images/awarddate2.jpg',1)"><img src="../images/awarddate.jpg" name="Image7" width="100" height="30" border="0" id="Image7" /></a></td>
</tr>
</table>
<p>&nbsp;</p></td>
<td width = "653" valign="top" bgcolor="#FFFFFF"><p align="center" class="style2"><br />
Formal Bids By Category <br />
</p>
<table align="center" border="1">
<tr>
<td width="15%" align="left" class="style3"><span class="style9">Bid Category </span></td>
<td width="15%" align="left" class="style3"><span class="style9">Bid Name</span></td>
<td width="15%" align="left" class="style10"> Opening Date </td>
<td width="15%"align="left" class="style10">Expiration Date </td>
<td align="left" class="style10"> Description </td>
</tr>
<tr><td></td></tr>
<% 
While ((Repeat1__numRows <> 0) AND (NOT rsCategory.EOF)) 
%>
 
<tr>
<td width="15%" align="left" class="style3"><span class="style2 style3 style7"><span class="style3"><strong><%=(rsCategory.Fields.Item("BidCategory").Value)%></strong></span></span></td>
<td width="15%" align="left" class="style3"><a href="categorydetails.asp?<%= Server.HTMLEncode(MM_keepBoth) & MM_joinChar(MM_keepBoth) & "BidsKey=" & rsCategory.Fields.Item("BidsKey").Value %>" target="_blank"><%=(rsCategory.Fields.Item("BidName").Value)%></a></td>
<td width="15%" align="left" class="style3">
<% If IsNull (rsCategory.Fields.Item("OpeningDate").Value) then
Response.Write("&nbsp;")
Else
Response.Write(rsCategory.Fields.Item("OpeningDate").Value)
End If
%>
</td>
<td width="15%" align="left" class="style3"><% If IsNull (rsCategory.Fields.Item("ExpirationDate").Value) then
Response.Write("&nbsp;")
Else
Response.Write(rsCategory.Fields.Item("ExpirationDate").Value)
End If
%> </td>
<td align="left" class="style3"><%=(rsCategory.Fields.Item("BidDescription").Value)%> </td>
</tr>
<tr><td></td></tr>
<% 
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsCategory.MoveNext()
Wend
%>
</table>
<p align="center" class="style2 style3">&nbsp;</p>
<span class="style3"><br>
</span>
<table border="0" width="50%" align="center">
<tr>
<td width="23%" align="center" class="style3"><% If MM_offset <> 0 Then %>
<a href="<%=MM_moveFirst%>">First</a>
<% End If ' end MM_offset <> 0 %> </td>
<td width="31%" align="center" class="style3"><% If MM_offset <> 0 Then %>
<a href="<%=MM_movePrev%>">Previous</a>
<% End If ' end MM_offset <> 0 %> </td>
<td width="23%" align="center" class="style3"><% If Not MM_atTotal Then %>
<a href="<%=MM_moveNext%>">Next</a>
<% End If ' end Not MM_atTotal %> </td>
<td width="23%" align="center" class="style3"><% If Not MM_atTotal Then %>
<a href="<%=MM_moveLast%>">Last</a>
<% End If ' end Not MM_atTotal %> </td>
</tr>
</table>
<p>&nbsp;</p>
<div align="center"><span class="style3">Records <%=(rsCategory_first)%> to <%=(rsCategory_last)%> of <%=(rsCategory_total)%> </span> </div>
<p>&nbsp;</p>
<p align="center"><!-- #BeginLibraryItem "/library/back.lbi" --><a href="javascript:history.back(1)"><img src="../../../../library/back.gif" width="116" height="34" border="0" /></a><!-- #EndLibraryItem --></p></td>
</tr>
</table>
</body>
</html>
<%
rsCategory.Close()
Set rsCategory = Nothing
%>
meichmann is offline   Reply With Quote
Old 04-18-2008, 07:48 PM   #2
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

hi mate

sorry im not an ASP guy but your Q will get answerd

just thought id comment on your connection file path

thats one doozy of a path. how deep is that script?
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 04-19-2008, 03:35 AM   #3
mangofreak
mangofreak's Avatar
 
Join Date: Jan 2006
Location: Toronto-Canada
Posts: 444
Default

can you explain a bit more:

"What I need to do is incorporate a postback function so people can search the results on that page to further "

Just to make sure we are in the same page.

post back how??? do you mean a search form??
__________________
J.
DW | FW | HTML | CSS | ASP | some PHP | Windows | Ubuntu
mangofreak is offline   Reply With Quote
Reply


Thread Tools
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

Forum Jump


All times are GMT. The time now is 12:09 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com