Random Error messages

C

C Downey

Hi Guys,

I am well into development of an ASP.NET application.

I have it built so I have a DAL that talks to my codebehind pages, which
determine what to write out to the screen. All my data classes use stored
procedures.

90% of the time this code works but sometimes I get errors(If I sit and hit
refresh 100 times, I will get errors approx 10 times):

The errors are
- Internal connection fatal error, System.Data at
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior,
RunBehavior runBehavior, Boolean returnStream)

- A severe error occurred on the current command. The results, if any,
should be discarded. .Net SqlClient Data Provider at
System.Data.SqlClient.SqlCommand.ExecuteReader

These all seem to be SQL Server connection problems associated with the
SQLCommand.ExecuteReader.

An example method from my Data Access Layer class is below:

Any help would be greatly appreciated!

Public Function getUserPreferenceIDs() As ArrayList

Dim conn As New SqlConnection(Common.ConnString)
Dim cmd As SqlCommand
Dim para As SqlParameter
Dim dr As SqlDataReader
Dim arr As New ArrayList()

conn.Open()

cmd = New SqlCommand("portGetUserPreferenceIDs", conn)
cmd.CommandType = CommandType.StoredProcedure

para = cmd.Parameters.Add(New SqlParameter("@contactID",
SqlDbType.Int))
para.Direction = ParameterDirection.Input
para.Value = _contactid

dr = cmd.ExecuteReader

Do While dr.Read()

If Not dr("ID").Equals(System.DBNull.Value) Then
arr.Add(dr("ID"))
End If

Loop

dr.Close()
conn.Close()

Return arr

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top