Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 9th, 2013, 07:22 AM
Registered User
Points: 43, Level: 1
Points: 43, Level: 1 Points: 43, Level: 1 Points: 43, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2012
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation on running sql procedure ,throwing time out error

Hi ,
can some one please help me on this.

My sql procedure to compare 2 comma seperated rows from consecutive rows is running fine when I execute from database.After passing parameters from front end it is throwing time out error.Not sure why this is happening...
here is my procedure:



alter Proc [dbo].[GetLatestPhasesEditHistory]
@ProjectID int
-- [GetLatestPhasesEditHistory] 216
As Begin

Declare @new varchar(1000),@old varchar(1000),@return varchar(1000), @i int, @tblCnt int
,@UpdatedDate datetime,@UpdatedBy varchar(10),@Phase varchar(1000)


If object_id('dbo.#t') is not null Begin ; drop table dbo.#t ;End
CREATE TABLE dbo.#t(Phase varchar(1000),UpdatedDate datetime,UpdatedBy varchar(10));
--CREATE INDEX IDX_phase ON #t(Id)

if (select COUNT(*) from phase WHERE PROJECT_ID=@ProjectID ) > 0
BEGIN
Set @tblCnt = (select COUNT(*) from phase WHERE PROJECT_ID=@ProjectID )
Set @i=1
While @i != (@tblCnt) Begin
set @new= (Select top 1 phase from (select Top (@i) phase,ID from Phase where project_id=@ProjectID order by ID desc) a order by ID asc)
set @old=(Select top 1 phase from (select Top (@i + 1) phase,ID from Phase where project_id=@ProjectID order by ID desc) a order by ID asc)
set @UpdatedDate=(select top 1 UpdatedDate from (select Top (@i)UpdatedDate,ID from phase where project_id=@ProjectID order by ID desc)a order by ID asc)
set @UpdatedBy= (select top 1 UpdatedBy from (Select top(@i) UpdatedBy,ID from phase where project_id=@ProjectID order by ID desc)a order by ID asc)
INSERT INTO #t (Phase)
exec [dbo].[PMT_GetPhasesEditHistory] @strN = @new,@strO = @old
--Update #t set UpdatedBy = @UpdatedBy, UpdatedDate=@UpdatedDate where Id = (select max(ID) from #t)
Set @i = @i +1
End
set @old = (Select top 1 phase from (select Top (@tblCnt) phase,ID from Phase where project_id=@ProjectID order by ID desc) a order by ID asc)
set @UpdatedDate=(Select top 1 UpdatedDate from (select Top (@tblCnt) UpdatedDate,ID from Phase where project_id=@ProjectID order by ID desc) a order by ID asc)
set @UpdatedBy= (Select top 1 UpdatedBy from (select Top (@tblCnt) UpdatedBy,ID from Phase where project_id=@ProjectID order by ID desc) a order by ID asc)
INSERT INTO #t (Phase,UpdatedDate,UpdatedBy) Values (@old,@UpdatedDate,@UpdatedBy)
END
select Phase,UpdatedDate,UpdatedBy from #t
drop table #t;
End

---------------------------------------------------------------------------------

My asp code for this is :

<%

Set objConnPhase=Server.CreateObject("ADODB.Connection ")
objConnPhase.CommandTimeout = 120
Set objRSPhase=Server.CreateObject("ADODB.Recordset")
Set ObjcmdPhase=Server.CreateObject("ADODB.Command")
objConnPhase.Open Application("conn")
Set ObjcmdPhase.ActiveConnection = objConnPhase
ObjcmdPhase.CommandText = "GetLatestPhasesEditHistory"
ObjcmdPhase.CommandType = adCmdStoredProc
ObjcmdPhase.Parameters.Append ObjcmdPhase.CreateParameter("@ProjectID", adInteger, adParamInput, 4, strProjectId)
set objRSPhase= ObjcmdPhase.Execute

%>
<%If Not (objRSPhase.BOF and objRSPhase.EOF) Then%>

<table id="tblphase" cellspacing="0" cellpadding="0" border="0" class="gridlines">
<tr class="grdHeading" align="left" style="font-weight:bold;white-space:nowrap;">
<%For intCol = 0 To 3%>
<th align="left">
<B><%=objRSPhase(intCol).Name%></B>
</th>
<% Next %>
</tr>
<%While Not objRSPhase.EOF %>
<tr class="grdRow">
<%For each item in objRSPhase.Fields %>
<td><%=cstr(objRSPhase(item.Name)) %></td>
<% Next %>
</tr>
<%objRSPhase.MoveNext %>
<%Wend%>
</table>
<%else %>
<div class="errormsg">No records could be found.</div>
<%End If%>


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help: Run Time Error -40036 While running the macro for copy and paste vamsidhar BOOK: Excel 2007 VBA Programmer's Reference ISBN: 978-0-470-04643-2 2 June 22nd, 2010 08:08 AM
Config Error Running Time Tracker Solution Margaret BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 3 June 23rd, 2009 06:52 AM
Throwing Security Exception Error Manoj Bisht ASP.NET 3.5 Professionals 2 March 28th, 2009 01:52 AM
Error When Running Stored Procedure Dwizz SQL Server 2000 4 May 15th, 2007 09:07 AM
Error catching and throwing - code rjp Access VBA 1 August 25th, 2004 08:32 PM





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