Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1380
  • Last Modified:

Timeout expired useing vb.net with sql 2005

Hi,
 experts,

I am execute store proce. thru vb.net i geting error Timeout expired

store procedur has 155 line

        cn = New SqlClient.SqlConnection(STR01)

        If cn.State = ConnectionState.Closed Then
            cn.Open()
        Else
            cn.Close()
            cn.Open()
        End If
        'cm.CommandTimeout = 1800
        cm = New SqlClient.SqlCommand(str1, cn)
        cm.CommandType = CommandType.StoredProcedure
        Dim para As SqlClient.SqlParameter
        para = cm.Parameters.Add("@Path", SqlDbType.NVarChar, 250)
        para.Value = TextBox1.Text

        para = cm.Parameters.Add("@Type", SqlDbType.NVarChar, 4)
        para.Value = "Full"
        CommExesp = cm.ExecuteNonQuery()
        Return CommExesp
        Exit Function
0
JAYANSPX
Asked:
JAYANSPX
  • 3
1 Solution
 
DhaestCommented:
If you run your stored procedure on sql-server, how long does it take than to execute ?
0
 
JAYANSPXAuthor Commented:

i run stored prodcedure on sql-server it's take 42 sec.

i am setting  timeout

cm.CommandTimeout = 1800

but still i geting that erro
0
 
DhaestCommented:
Do you have this in your stored procedure ?
SET NOCOUNT ON
0
 
DhaestCommented:
This didn't solve it ?
cm = New SqlClient.SqlCommand(str1, cn)
cm.CommandTimeout = 2000

0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now