Question Wierd Timeout Errors when Accessing SQL Database.

xzibited2

Active member
Joined
Jul 9, 2008
Messages
26
Programming Experience
1-3
I've designed a pretty simple program that allows a user to input information on an existing service ticket. The program briefly connects to a SQL database and pulls one piece of information (The customer who opened the ticket) and uses that information to dictate what pieces of information are required for that specific customer. When the app was in BETA testing, I had no issues connecting and pulling the data. However, recently several users have reported getting timeout errors and 'named pipes provider Error 40, could not open up a connection to SQL Server' when connecting to the database. Here is the code:

VB.NET:
Dim strconnection As String = "Data Source={mydatabase};Initial Catalog={mycatalog};Integrated Security=SSPI;"
                Dim cn As SqlConnection = New SqlConnection(strconnection)
                cn.Open()
                Dim strSelect As String = "select entityname from event p inner join entity s on p.groupassigned = s.entityinternalid where eventinternalid = '" + TextBox12.Text + "'"
                Dim dscmd As New SqlDataAdapter(strSelect, cn)
                Dim ds As New DataSet()
                dscmd.Fill(ds, "entityname")
                cn.Close()
                Dim dt As DataTable = ds.Tables.Item("entityname")
                Dim rowCustomer As DataRow
                For Each rowCustomer In dt.Rows
                    LinkLabel1.Text = rowCustomer.Item("entityname")
                Next
                If dt.Rows.Count = 0 Then
                    MsgBox("This Event ID does not Exist!", MsgBoxStyle.Critical, "SolvClose v2.0")
                    TextBox12.Text = ""
                End If

The timeout problem does not occur with every user of the program, but when it does occur, restarting their computer is the only thing that seems to have an effect (although sometimes that does not even help). I've managed to get it to occur on my computer once, and was able to run it through some debugging. The program fails right on the
VB.NET:
cn.open()
command.

The weird thing about it is that I am able to successfully run a command through osql via the command prompt when the problem is occurring.

I've tried several different connection strings and modifying the code slightly, but I'm fairly confident its not the code because it is an intermittent issue. I've looked up both the timeout error and the error 40, and tried several adjustments on the user's computers, including tweaking port settings on windows firewall, but to no avail. Any thoughts on this?
 
You can try following the advice given in the DW2 link in my signature to do your data access (the way you do it here is very old, .net 1 style, and you need to update). Note that DW2 is for .net 2. Some areas will be updated in .net 3.5 so refer to the latest pages wherever possible
 
I tried that, but the only option I have for a data provider is SQL Server Compact 3.5, I cant event Select Microsoft SQL Server as an option in the data source.
 
If you're using VB Express you should have at least the three data sources "Access file", "Sql Compact" and "Sql database file" available, each have their own providers. The latter could be dependent on whether you have installed Sql/Express also in addition to the Sql Compact.
 
I did some hunting around, and I'm being told that I cannot connect to SQL server 2000 from Express editions using IDE, I would have to use the sqlconnectionclass....which kind of puts me back at square one unless anyone knows of a workaround.
 

Latest posts

Back
Top