Solved

VB.net calling stored procedure times out about 50% of the time

Posted on 2009-05-15
6
152 Views
Last Modified: 2013-11-26
I have a stored procedure ln a sql 2k database.  I call the s/p from a vb.net application it works well about half of hte time .... the other half it fails with the following error...
Timout Expired. The timout period elapsed prior to completion of the operation or the server is not responding.

I have been playing with the connection timeouts, but it does not seem to change anything.. as I am a newbie it could be that I am not using them correctly ... thanks for the help
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeleteOne.Click

        Dim con As New SqlClient.SqlConnection
 

        Dim da As New OleDb.OleDbDataAdapter

        Dim ds As New DataSet

        Dim sql As SqlClient.SqlCommand

        Dim cb As New OleDb.OleDbCommandBuilder(da)

        Dim Server As String

        Dim Firstname As String = txtFirstName.Text

        Dim Surname As String = txtSurName.Text

        Dim UserInit As String = txtUserInit.Text

        Dim Result As Integer = "0"

        Dim ResultText As String = ""

        Server = txtIPAddress.Text
 

        con = New SqlClient.SqlConnection("Data Source =" & Server & ";initial catalog = Windman;User ID=user;Password=pass;Connect Timeout = 0")

        con.Open()
 

        sql = New SqlClient.SqlCommand("WMS_SP_UTL_DeleteUser", con)

        With sql

            .CommandType = CommandType.StoredProcedure

            '//add some parameters

            .Parameters.Add(New SqlClient.SqlParameter("@UserInitials", UserInit))

            .Parameters.Add(New SqlClient.SqlParameter("@Result", 0))

            .Parameters.Add(New SqlClient.SqlParameter("@Resulttext", ""))
 

            Try

                .ExecuteNonQuery()

                MsgBox(UserInit & " deleted from " & Server)

            Catch excA As SqlClient.SqlException

                MsgBox(excA.Message)

            End Try

        End With
 

    End Sub

Open in new window

0
Comment
Question by:NCSA SCADA
  • 4
  • 2
6 Comments
 
LVL 11

Expert Comment

by:srikanthreddyn143
Comment Utility
specify commandtimeout property to Zero

CommandObject.CommandTimeout = 0
0
 
LVL 11

Expert Comment

by:srikanthreddyn143
Comment Utility
Try that
0
 

Author Comment

by:NCSA SCADA
Comment Utility
is this in my connection string
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 11

Expert Comment

by:srikanthreddyn143
Comment Utility
With sql
            .CommandType = CommandType.StoredProcedure
            .CommandTimeout = 0
0
 
LVL 11

Accepted Solution

by:
srikanthreddyn143 earned 500 total points
Comment Utility
and also close the connection
0
 

Author Closing Comment

by:NCSA SCADA
Comment Utility
Thanks for the help - it worked great
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now