I have the following block of code in my program:
The problem is that it gets stuck at the highlighted lines somethimes, but not always.Code:'' create a command object Dim cmd As New SqlCommand cmd.CommandText = "SomeStoredProc" cmd.CommandType = CommandType.StoredProcedure cmd.CommandTimeout = 0 cmd.Parameters.AddRange(SpParmList.ToArray) ' SpParmList is a List of parameters '' Get records from database Using cnn As New SqlClient.SqlConnection(DbConnectionString) cnn.Open() cmd.Connection = cnn Using reader As SqlDataReader = cmd.ExecuteReader() '<-- this line myDS.Load(reader) End Using End Using
Sometimes it takes just a few seconds on that line, while at other times it takes even more than half an hour, for the same stored procedure.
Note: The stored procedure returns millions of records.
Anyone knows why this happens and what can be done for this?




icon on the left of the post.
Reply With Quote
