Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: Database: MS SQL Server
 Using a Stored Procedure within Snitz Code
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Jeepaholic
Average Member

USA
697 Posts

Posted - 04 December 2003 :  00:05:18  Show Profile  Visit Jeepaholic's Homepage
Since I'm a bit clueless regarding how Snitz does database access (or how Classic ASP does it for that matter), I'm in need of some help.

I've got a stored procedure that I've written that I'd like an INCLUDE file (within inc_header.asp) to access and display information from.

1) What would the code look like to call this stored procedure within Snitz code? The SP is located within the Snitz database.
2) What would the code look like to step through each record and pull data?

Something to note is that the SP returns more than one recordset (long story), however, I'm only interested in the first one for this application.

Thanks for the help!

Al Bsharah
Aholics.com

Jeepaholics Anonymous
Broncoholics Anonymous
Network Insight

Edited by - Jeepaholic on 04 December 2003 00:19:35

redbrad0
Advanced Member

USA
3725 Posts

Posted - 04 December 2003 :  00:31:08  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
I believe this is the correct code....


<%
	'How many records per page do we want to show?
	Const iRecordsPerPage = 10

	Dim currentPage	 'what page are we on??
	Dim bolLastPage	 'are we on the last page?
	
	if len(Request.QueryString("page")) = 0 then
		currentPage = 1
	else
		currentPage = CInt(Request.QueryString("page"))
	end if

	'Show the paged results
	strSQL = "sp_PagedItems " & currentPage & "," & iRecordsPerPage
	objRS.Open strSQL, my_Conn
	
	'See if we're on the last page
	if Not objRS.EOF then
		if CInt(objRS("MoreRecords")) > 0 then
			bolLastPage = False
		else
			bolLastPage = True
		end if
	end if
%>
<P>

<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 ALIGN=CENTER>
<TR><TH COLSPAN=2 BGCOLOR=NAVY>
	<FONT SIZE=+1 COLOR=WHITE>
		List of Items
	</FONT>
</TH></TR>
<%
	Do While Not objRS.EOF %>
		<TR><TD ALIGN=LEFT BGCOLOR=GRAY>
			<%=objRS("Name")%>
		</TD><TD ALIGN=CENTER BGCOLOR=GRAY>
			<%=FormatCurrency(objRS("Price"))%>
		</TD></TR>
<%		objRS.MoveNext
	Loop %>
</TABLE>
<P>
<CENTER>
<%
'Only show the previous button if we are NOT on the first page
if currentPage > 1 then %>
  <INPUT TYPE=BUTTON VALUE="<< Previous <%=iMaxRecords%> Records"
  ONCLICK="document.location.href='thispage.asp?page=<%=currentPage-1%>'">
       
<% end if 

'Only show the next button if we are NOT on the last page
if Not bolLastPage then %>
  <INPUT TYPE=BUTTON VALUE="Next <%=iMaxRecords%> Records >>"
  ONCLICK="document.location.href='thispage.asp?page=<%=currentPage+1%>'">
<% end if %>
</CENTER>

Brad
Oklahoma City Online Entertainment Guide
Oklahoma Event Tickets
Go to Top of Page

Jeepaholic
Average Member

USA
697 Posts

Posted - 04 December 2003 :  03:27:14  Show Profile  Visit Jeepaholic's Homepage
Thanks, that did the trick... The only extra piece I needed was...

set objRS = Server.CreateObject("ADODB.Recordset")

...with a little hunting, I found it. Thanks Brad!

Al Bsharah
Aholics.com

Jeepaholics Anonymous
Broncoholics Anonymous
Network Insight
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 04 December 2003 :  07:09:08  Show Profile  Send ruirib a Yahoo! Message
You can also create the recordset using the Execute method of the connection object, for stored procs that return recordsets. To use stored procs that do not return recordsets, you need to use the very same Execute method.

The syntax for the execute method invocation in the latter case is described here.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Jeepaholic
Average Member

USA
697 Posts

Posted - 04 December 2003 :  11:09:53  Show Profile  Visit Jeepaholic's Homepage
Good thread, thanks!

Al Bsharah
Aholics.com

Jeepaholics Anonymous
Broncoholics Anonymous
Network Insight
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 04 December 2003 :  11:14:06  Show Profile  Send ruirib a Yahoo! Message
You're welcome .


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.17 seconds. Powered By: Snitz Forums 2000 Version 3.4.07