So I recently came across the Internal connection fatal error for a report written in ASP.NET that I had inherited. This error was a bit troubling because the logic in the report caught exceptions, but I kept getting this error message. Well after looking more closely at the code, it was making tons and tons of calls to the database that weren't necessary. For example, for reach row returned from the main result set the gridview was using, on the RowDataBound it would make an additional 4 calls to the database for other data. So in a sense say you have 100 records returned you're looking at 400+ connection calls to the database. Imagine 200, 300 or more records returned, the connections it would need to make are unreasonable.
So to solve this situation, I rewrote the code that connects to the database by limiting the connections to the database to only a few. The reason this worked for my situation is because I just pulled in all the data I know I would need and use For Each blocks like the one below
For Each dr As DataRow In ds.Tables(0).Select(String.Format("SOME_ID = {0}", e.Row.DataItem("SOME_ID")))
'You code here
Next
The previous code was something like this
Dim strSql As String = "sql statement here WHERE SOME_ID = {0}"
ds = class.GoGetSqlStatement(strSql)
So as you can see it was a making a call each time based off the ID, where I just brought in all the data and did a Select on the dataset based off the ID to eliminate connections. Now, is the the correct solution to the problem, I'm not sure because it doesn't seem there is one. However, knocking down the connections to the DB is an excellent start. So analyze your code and see if that could be an issue. Good luck - John
888ffa49-b30f-44c3-9e96-fbb77005e68a|0|.0
ASP.NET
asp.net, sql