Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-05-15
6
Medium Priority
?
164 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 11

Expert Comment

by:srikanthreddyn143
ID: 24398440
specify commandtimeout property to Zero

CommandObject.CommandTimeout = 0
0
 
LVL 11

Expert Comment

by:srikanthreddyn143
ID: 24398444
Try that
0
 

Author Comment

by:NCSA SCADA
ID: 24398455
is this in my connection string
0
Quick Start: DOCKER

Sometimes you just need a Quick Start on a topic in order to begin using it.. this is just what you need to know to get up and running with Docker!

 
LVL 11

Expert Comment

by:srikanthreddyn143
ID: 24398463
With sql
            .CommandType = CommandType.StoredProcedure
            .CommandTimeout = 0
0
 
LVL 11

Accepted Solution

by:
srikanthreddyn143 earned 2000 total points
ID: 24398473
and also close the connection
0
 

Author Closing Comment

by:NCSA SCADA
ID: 31582048
Thanks for the help - it worked great
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

705 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