Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have created stored procedure to select record but it may works for sometime and sometimes it gives timeout. Even when there's only 1 record in the database.
Posted
Updated 17-Sep-12 3:22am
v2
Comments
bbirajdar 17-Sep-12 9:22am    
You need to contact your network administrator. The network connection is dropping...
bhargavpp 18-Sep-12 0:56am    
CREATE Procedure [dbo].[usp_storedName]
(
@Param1 int = NULL,
@Param1 int = NULL
)
as
SET NOCOUNT ON

Select * From (

Select t1.column1,t1.column2,t3.column4,t2.column5,t1.column6,t1.column7
From
table1 t1
Inner Join table2 t2 On ISD.ItemId = I.ItemId and i.InPcs = 1 and ISD.SubItemId <> 0
Inner Join table3 t3 On I.GroupId = IG.GroupId
Where somecondition
UNION ALL

Select t1.column1,t1.column2,t3.column4,t2.column5,t1.column6,t1.column7
From
table1 t1
Inner Join table2 t2 On ISD.ItemId = I.ItemId and i.InPcs = 1 and ISD.SubItemId <> 0
Inner Join table3 t3 On I.GroupId = IG.GroupId
Where somecondition
) as Q1

Where

( @Param1 Is Null or Q1.BranchId = @Param1) And
( @Param2 Is Null or Q1.ParentId = @Param2)

this is my stored procedre . when i am executing from database it is fast executing and result in 01 sec while executing from Executing nonwuery then it will take time for sometime and gives timeout the alternate solution of same is replace column name instead of * then i will work for 1 day then after we have to chenge it by column name this alternate will contiune..
Dinesh Ambaliya 17-Sep-12 9:28am    
There should be something wrong in your stored procedure. We cannot say anything without seeing your stored procedure.
bhargavpp 18-Sep-12 0:56am    
CREATE Procedure [dbo].[usp_storedName]
(
@Param1 int = NULL,
@Param1 int = NULL
)
as
SET NOCOUNT ON

Select * From (

Select t1.column1,t1.column2,t3.column4,t2.column5,t1.column6,t1.column7
From
table1 t1
Inner Join table2 t2 On ISD.ItemId = I.ItemId and i.InPcs = 1 and ISD.SubItemId <> 0
Inner Join table3 t3 On I.GroupId = IG.GroupId
Where somecondition
UNION ALL

Select t1.column1,t1.column2,t3.column4,t2.column5,t1.column6,t1.column7
From
table1 t1
Inner Join table2 t2 On ISD.ItemId = I.ItemId and i.InPcs = 1 and ISD.SubItemId <> 0
Inner Join table3 t3 On I.GroupId = IG.GroupId
Where somecondition
) as Q1

Where

( @Param1 Is Null or Q1.BranchId = @Param1) And
( @Param2 Is Null or Q1.ParentId = @Param2)

this is my stored procedre . when i am executing from database it is fast executing and result in 01 sec while executing from Executing nonwuery then it will take time for sometime and gives timeout the alternate solution of same is replace column name instead of * then i will work for 1 day then after we have to chenge it by column name this alternate will contiune..
fjdiewornncalwe 17-Sep-12 9:29am    
How about showing us the procedure. Without that how are we suppose to magically guess what that looks like. We don't read minds, even if it sometimes seems like some of the CPians have that ability.

1 solution

do one thing just tweak the execution time out for ur stored procedure in .cs page where u call ur stored procedure, also configure ur application
 
Share this answer
 
Comments
fjdiewornncalwe 17-Sep-12 9:36am    
Not a good idea because it does not address the root of the issue. The root of the issue is either a connectivity issue as aspnet_regiis notes in his comment, or that the procedure itself has issues within it. Simply increasing a timeout does nothing but mask the issue temporarily.
bhargavpp 18-Sep-12 0:55am    
CREATE Procedure [dbo].[usp_storedName]
(
@Param1 int = NULL,
@Param1 int = NULL
)
as
SET NOCOUNT ON

Select * From (

Select t1.column1,t1.column2,t3.column4,t2.column5,t1.column6,t1.column7
From
table1 t1
Inner Join table2 t2 On ISD.ItemId = I.ItemId and i.InPcs = 1 and ISD.SubItemId <> 0
Inner Join table3 t3 On I.GroupId = IG.GroupId
Where somecondition
UNION ALL

Select t1.column1,t1.column2,t3.column4,t2.column5,t1.column6,t1.column7
From
table1 t1
Inner Join table2 t2 On ISD.ItemId = I.ItemId and i.InPcs = 1 and ISD.SubItemId <> 0
Inner Join table3 t3 On I.GroupId = IG.GroupId
Where somecondition
) as Q1

Where

( @Param1 Is Null or Q1.BranchId = @Param1) And
( @Param2 Is Null or Q1.ParentId = @Param2)

this is my stored procedre . when i am executing from database it is fast executing and result in 01 sec while executing from Executing nonwuery then it will take time for sometime and gives timeout the alternate solution of same is replace column name instead of * then i will work for 1 day then after we have to chenge it by column name this alternate will contiune..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900