473,672 Members | 2,615 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP with stored procedure problem....

I have written a stored procedure which will paging the recordset, and
return a range of record that i need, and i write a asp code to call it
however, no any return after the set objRs = objCmd.Execute
when i try to Response.write (objRs.recordco unt)
it said the recordset is close....

how can i solve this problem?? thx
=============== =====
Here is my stored procedure
=============== =====

CREATE PROCEDURE sp_admin_member _searching
@request_page INT = 1,
@page_size INT = 0,
@id INT = 0,
@membership_id INT = 0,
@area_id INT = 0,
@return_page INT = 0 OUTPUT,
@total_records INT = 0 OUTPUT,
@total_pages INT = 0 OUTPUT
AS
BEGIN
DECLARE
@sql_request NVARCHAR(4000)
-- create temp table to store all member information
CREATE TABLE #temp(
record_id INT IDENTITY(1, 1),
id INT,
membership_id INT,
Company_name_tc NVARCHAR(50),
Company_name_en CHAR(100),
register_date DATETIME
)
-- initial sql statement to insert company record to temp table
SET @sql_request = N'INSERT INTO #temp (id, membership_id, Company_name_tc ,
Company_name_en , register_date) '
SET @sql_request = @sql_request + N'SELECT id, membership_id,
company_name_tc , company_name_en , register_date FROM tblCompanyInfor mation '
SET @sql_request = @sql_request + N'WHERE 1 = 1 '

-- determine user have provide id or not
IF @id > 0 SET @sql_request = @sql_request + N'AND id = ' + CAST(@id AS
NVARCHAR) + ' '

-- determine user have provide membership id or not
IF @membership_id <> '' SET @sql_request = @sql_request + N'AND
membership_id = ' + CAST(@membershi p_id AS NVARCHAR) + ' '

-- determine user have provide area id or not
IF @area_id <> '' SET @sql_request = @sql_request + N'AND area_id = ' +
CAST(@area_id AS NVARCHAR) + ' '

SET @sql_request = @sql_request + N'ORDER BY id ASC'

-- execute insert record statement
EXECUTE sp_executesql @sql_request

-- get total records count
SET @total_records = @@ROWCOUNT

-- get total page
SET @total_pages = @total_records / @page_size
IF (@total_records % @page_size) <> 0 SET @total_pages = @total_pages + 1

-- set current page position
IF @request_page > @total_pages
SET @request_page = 1
ELSE IF @request_page < 1
SET @request_page = @total_pages
-- return the next page number
SET @return_page = @request_page

-- initial sql statement to paging the result
IF @request_page = 1
BEGIN
SELECT id, membership_id, Company_name_tc , Company_name_en , register_date
FROM #temp
WHERE record_id >= ((@request_page - 1) * @page_size) AND record_id <=
(@request_page * @page_size)
ORDER BY Company_name_en ASC
END
ELSE
BEGIN
SELECT id, membership_id, Company_name_tc , Company_name_en , register_date
FROM #temp
WHERE record_id >= (((@request_pag e - 1) * @page_size) + 1) AND record_id
<= (@request_page * @page_size)
ORDER BY Company_name_en ASC
END
DROP TABLE #temp
END

=============== =====
here is my ASP code
=============== =====
dim objCn, objRs, objCmd, objParam
dim iPageSize, iTotalRecords, iTotalPages, iPage

set objCn = getConnection ()
set objCmd = getCommand(objC n, "sp_admin_membe r_searching", 4, true)

iPageSize = 10
iTotalRecords = 0
iTotalPage = 0

'@ determine command parameter
set objParam = objCmd.createPa rameter ("request_page" , 3, 1,
request("page") )
objCmd.Paramete rs.append objParam
set objParam = objCmd.createPa rameter ("page_size" , 3, 1, iPageSize)
objCmd.Paramete rs.append objParam
set objParam = objCmd.createPa rameter ("id", 3, 1, 0)
objCmd.Paramete rs.append objParam
set objParam = objCmd.createPa rameter ("membership_id ", 3, 1, 0)
objCmd.Paramete rs.append objParam
set objParam = objCmd.createPa rameter ("area_id", 3, 1, 0)
objCmd.Paramete rs.append objParam
set objParam = objCmd.createPa rameter ("return_pag e", 3, 2, iPage)
objCmd.Paramete rs.append objParam
set objParam = objCmd.createPa rameter ("total_records ", 3, 2,
iTotalRecords)
objCmd.Paramete rs.append objParam
set objParam = objCmd.createPa rameter ("total_page s", 3, 2,
iTotalPages)
objCmd.Paramete rs.append objParam

set objRs = objCmd.execute

releaseDataObje ct (objCmd)
releaseDataObje ct (objRs)
releaseDataObje ct (objCn)
Jul 19 '05 #1
7 4518
Try doing:

CREATE PROCEDURE sp_admin_member _searching
@request_page INT = 1,
@page_size INT = 0,
@id INT = 0,
@membership_id INT = 0,
@area_id INT = 0,
@return_page INT = 0 OUTPUT,
@total_records INT = 0 OUTPUT,
@total_pages INT = 0 OUTPUT
AS
BEGIN
SET NOCOUNT ON
-- rest of your sp

Ray at home

"Vitamin" <ha*@seeWhat.co m> wrote in message
news:u8******** ******@TK2MSFTN GP12.phx.gbl...
I have written a stored procedure which will paging the recordset, and
return a range of record that i need, and i write a asp code to call it
however, no any return after the set objRs = objCmd.Execute
when i try to Response.write (objRs.recordco unt)
it said the recordset is close....

how can i solve this problem?? thx
=============== =====
Here is my stored procedure
=============== =====

CREATE PROCEDURE sp_admin_member _searching
@request_page INT = 1,
@page_size INT = 0,
@id INT = 0,
@membership_id INT = 0,
@area_id INT = 0,
@return_page INT = 0 OUTPUT,
@total_records INT = 0 OUTPUT,
@total_pages INT = 0 OUTPUT
AS
BEGIN
DECLARE
@sql_request NVARCHAR(4000)


&c.
Jul 19 '05 #2
no other problems..
it seems cannot get the input value from ASP Command
although i set the page_size parameters = 1
it still prompt me error that "Divide by zero error encountered. ".....

"Ray at <%=sLocation% >" <myfirstname at lane 34 . komm> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
Try doing:

CREATE PROCEDURE sp_admin_member _searching
@request_page INT = 1,
@page_size INT = 0,
@id INT = 0,
@membership_id INT = 0,
@area_id INT = 0,
@return_page INT = 0 OUTPUT,
@total_records INT = 0 OUTPUT,
@total_pages INT = 0 OUTPUT
AS
BEGIN
SET NOCOUNT ON
-- rest of your sp

Ray at home

"Vitamin" <ha*@seeWhat.co m> wrote in message
news:u8******** ******@TK2MSFTN GP12.phx.gbl...
I have written a stored procedure which will paging the recordset, and
return a range of record that i need, and i write a asp code to call it
however, no any return after the set objRs = objCmd.Execute
when i try to Response.write (objRs.recordco unt)
it said the recordset is close....

how can i solve this problem?? thx
=============== =====
Here is my stored procedure
=============== =====

CREATE PROCEDURE sp_admin_member _searching
@request_page INT = 1,
@page_size INT = 0,
@id INT = 0,
@membership_id INT = 0,
@area_id INT = 0,
@return_page INT = 0 OUTPUT,
@total_records INT = 0 OUTPUT,
@total_pages INT = 0 OUTPUT
AS
BEGIN
DECLARE
@sql_request NVARCHAR(4000)


&c.

Jul 19 '05 #3
i found that if i using connection.exec ute to instead of command object
it can work...but how can i get the return value from stored procedure...

thx~

"Ray at <%=sLocation% >" <myfirstname at lane 34 . komm> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
Try doing:

CREATE PROCEDURE sp_admin_member _searching
@request_page INT = 1,
@page_size INT = 0,
@id INT = 0,
@membership_id INT = 0,
@area_id INT = 0,
@return_page INT = 0 OUTPUT,
@total_records INT = 0 OUTPUT,
@total_pages INT = 0 OUTPUT
AS
BEGIN
SET NOCOUNT ON
-- rest of your sp

Ray at home

"Vitamin" <ha*@seeWhat.co m> wrote in message
news:u8******** ******@TK2MSFTN GP12.phx.gbl...
I have written a stored procedure which will paging the recordset, and
return a range of record that i need, and i write a asp code to call it
however, no any return after the set objRs = objCmd.Execute
when i try to Response.write (objRs.recordco unt)
it said the recordset is close....

how can i solve this problem?? thx
=============== =====
Here is my stored procedure
=============== =====

CREATE PROCEDURE sp_admin_member _searching
@request_page INT = 1,
@page_size INT = 0,
@id INT = 0,
@membership_id INT = 0,
@area_id INT = 0,
@return_page INT = 0 OUTPUT,
@total_records INT = 0 OUTPUT,
@total_pages INT = 0 OUTPUT
AS
BEGIN
DECLARE
@sql_request NVARCHAR(4000)


&c.

Jul 19 '05 #4
Your SP returns a recordset, correct?

Set objRS = connection.exec ute
''these are vars in your asp page
id = objRS.Fields.It em(0).Value
membership_id = objRS.Fields.It em(1).Value
Company_name_tc = objRS.Fields.It em(2).Value
Company_name_en = objRS.Fields.It em(3).Value
register_date = objRS.Fields.It em(4).Value

That would grab the values from the recordset. You could do that while loop
until objRS.EOF, or use objRS.GetRows() to put your recordset into a two
dimensional array. Is this what you mean, or are you asking things that I'm
not qualified to answer and should have just kept my mouth shut? :]

Ray at home

"Vitamin" <ha*@seeWhat.co m> wrote in message
news:uX******** ******@TK2MSFTN GP09.phx.gbl...
i found that if i using connection.exec ute to instead of command object
it can work...but how can i get the return value from stored procedure...

thx~

"Ray at <%=sLocation% >" <myfirstname at lane 34 . komm> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
Try doing:

CREATE PROCEDURE sp_admin_member _searching
@request_page INT = 1,
@page_size INT = 0,
@id INT = 0,
@membership_id INT = 0,
@area_

Jul 19 '05 #5
sorry
i think i am made you confuse.
i mean i cannot get the return value from a variable of stored procedure
which had define as OUTPUT
....

"Ray at <%=sLocation% >" <myfirstname at lane 34 . komm> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Your SP returns a recordset, correct?

Set objRS = connection.exec ute
''these are vars in your asp page
id = objRS.Fields.It em(0).Value
membership_id = objRS.Fields.It em(1).Value
Company_name_tc = objRS.Fields.It em(2).Value
Company_name_en = objRS.Fields.It em(3).Value
register_date = objRS.Fields.It em(4).Value

That would grab the values from the recordset. You could do that while loop until objRS.EOF, or use objRS.GetRows() to put your recordset into a two
dimensional array. Is this what you mean, or are you asking things that I'm not qualified to answer and should have just kept my mouth shut? :]

Ray at home

"Vitamin" <ha*@seeWhat.co m> wrote in message
news:uX******** ******@TK2MSFTN GP09.phx.gbl...
i found that if i using connection.exec ute to instead of command object
it can work...but how can i get the return value from stored procedure...
thx~

"Ray at <%=sLocation% >" <myfirstname at lane 34 . komm> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
Try doing:

CREATE PROCEDURE sp_admin_member _searching
@request_page INT = 1,
@page_size INT = 0,
@id INT = 0,
@membership_id INT = 0,
@area_


Jul 19 '05 #6
o...i know what problem it have
if i using set objRs = objCmd.execute
it will only return recordset
i cannot access the output parameter of stored procedure
if i using objCmd.execute only
then i can access the output parameter of stored procedure
shit...

"Ray at <%=sLocation% >" <myfirstname at lane 34 . komm> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Your SP returns a recordset, correct?

Set objRS = connection.exec ute
''these are vars in your asp page
id = objRS.Fields.It em(0).Value
membership_id = objRS.Fields.It em(1).Value
Company_name_tc = objRS.Fields.It em(2).Value
Company_name_en = objRS.Fields.It em(3).Value
register_date = objRS.Fields.It em(4).Value

That would grab the values from the recordset. You could do that while loop until objRS.EOF, or use objRS.GetRows() to put your recordset into a two
dimensional array. Is this what you mean, or are you asking things that I'm not qualified to answer and should have just kept my mouth shut? :]

Ray at home

"Vitamin" <ha*@seeWhat.co m> wrote in message
news:uX******** ******@TK2MSFTN GP09.phx.gbl...
i found that if i using connection.exec ute to instead of command object
it can work...but how can i get the return value from stored procedure...
thx~

"Ray at <%=sLocation% >" <myfirstname at lane 34 . komm> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
Try doing:

CREATE PROCEDURE sp_admin_member _searching
@request_page INT = 1,
@page_size INT = 0,
@id INT = 0,
@membership_id INT = 0,
@area_


Jul 19 '05 #7
yes~
i found the solution la~
thanks very much~~~

"Ray at <%=sLocation% >" <myfirstname at lane 34 . komm> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Your SP returns a recordset, correct?

Set objRS = connection.exec ute
''these are vars in your asp page
id = objRS.Fields.It em(0).Value
membership_id = objRS.Fields.It em(1).Value
Company_name_tc = objRS.Fields.It em(2).Value
Company_name_en = objRS.Fields.It em(3).Value
register_date = objRS.Fields.It em(4).Value

That would grab the values from the recordset. You could do that while loop until objRS.EOF, or use objRS.GetRows() to put your recordset into a two
dimensional array. Is this what you mean, or are you asking things that I'm not qualified to answer and should have just kept my mouth shut? :]

Ray at home

"Vitamin" <ha*@seeWhat.co m> wrote in message
news:uX******** ******@TK2MSFTN GP09.phx.gbl...
i found that if i using connection.exec ute to instead of command object
it can work...but how can i get the return value from stored procedure...
thx~

"Ray at <%=sLocation% >" <myfirstname at lane 34 . komm> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
Try doing:

CREATE PROCEDURE sp_admin_member _searching
@request_page INT = 1,
@page_size INT = 0,
@id INT = 0,
@membership_id INT = 0,
@area_


Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
10890
by: Michael Trosen | last post by:
Hi Everyone, I hope someone can help, I'm pretty new to pro*c programming. I have the following application setup: a pro*c program calls a stored procedure and recieves a cursor back: the cursor is defined as: SQL_CURSOR delpt_cursor
3
2800
by: Rhino | last post by:
I've spent the last couple of hours trying to figure out how to debug a Java stored procedure and am just going in circles. The last straw came when I got "Cannot open input stream for default" when I launched the IBM Distributed Debugger via D:\IBMDebug>idebug.exe -qdaemon -quiport=8000,8001 First, a bit of background. I am running DB2 V7.2 with Fixpack 9 applied on Windows XP Professional (all critical service applied). I've written...
7
15590
by: Jeff Wang | last post by:
Hi all, Can someone help me out? I've been struggling with this for almost a week and still have no clue what's wrong. Basically I want to write a DB2 stored procedure for OS/390 in REXX. In this procedure it reads a dataset and return the first line of the dataset. I met two problems: Problem 1:
8
7933
by: Thomasb | last post by:
With a background in MS SQL Server programming I'm used to temporary tables. Have just started to work with DB2 ver 7 on z/OS and stumbled into the concept of GLOBAL TEMPORARY TABLE. I have created a temporary database with a tables space. Verified that DECLARE GLOBAL TEMPORARY TABLE TEMP (A INTEGER); INSERT INTO SESSION.TEMP VALUES(10); SELECT A FROM SESSION.TEMP; works from a query tool.
2
9225
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered problems doing this. I wanted to implemented a generic "Helper" class like this: /** * Helper
6
6757
by: Wojciech Wendrychowicz | last post by:
Hello to All, I'm trying to retrieve records from AS/400 in an VBA application. So, I've made an RPG program, then a stored procedure wchich calls that RPG program, and finally some VBA code to call the stored procedure and retrieve data from AS/400. The problem is, that when I finally run my VB code, it just hangs. But when I call the same stored procedure from "pure" SQL - it works perfect. (I evaluate Aqua Data Studio 3.7) What I...
2
3327
by: Eli | last post by:
Hi all We currently have a strange problem with calling a Stored Procedure (SQL Database) in our C# Project. The only error I get is "System error" which says a lot :) Background: We have several stored procedures to Insert and update datas in our SQL database. Some stored procedures are smaller (insert datas in only one table) and some of them are quite big (insert datas in several
7
3452
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function 'UpdateRegistrant' expects parameter '@EMail', which was not supplied. The field value was null in the database and not changed in the FormView so is null going back into the stored procedure. I'm stumped and would greatly appreciate any suggestions.
4
3985
by: nishi57 | last post by:
I hope I can get some help regarding this issue, which has been going on for a while. I have a desktop user who is having problem running "Stored Procedures". The DB2 Connect application works fine but when he runs the stored procedure, he gets the following error message. "SYSPROC".CSGCSB54 - Run started. Data returned in result sets is limited to the first 100 rows. Data returned in result set columns is limited to the first 20...
9
4136
by: fniles | last post by:
I am using VB.NET 2003 and SQL2000 database. I have a stored procedure called "INSERT_INTO_MYTABLE" that accepts 1 parameter (varchar(10)) and returns the identity column value from that table. When calling the stored procedure from VB.NET, in the CommandText, can I just say "INSERT_INTO_MYTABLE '12345'" instead of calling it with "INSERT_INTO_MYTABLE" then do the following : OleDbCommand2.Parameters.Add("@Account", SqlDbType.VarChar, 10)...
0
8486
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8931
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8828
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8608
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7446
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6238
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4418
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.