SteveoAtilla Posted March 2, 2007 Posted March 2, 2007 Hello! I wasn't sure if this should go into the ASP.NET forum, or the Database forum, so I'll cross-post in both. Anyway, I have just started getting this error (trapped by a try...catch...end try structure) in an app that has been functioning well for over 18 months. I am getting this in my development environment (Windows XP machine with a Windows Server 2003 SQL virtual machine), and since I am trapping the error, I don't get the full stack trace. Anyway, I don't believe that there is a single set of commands that trigger the error, since I can comment out one of the subs with DB access, and I still get the error. Just for reference, here is one of the DB routines anyway: Dim ProductionBOMCmdText As String Dim ProductionBOMCommand As New SqlCommand ProductionBOMCmdText = "UPDATE dbo.ProductionBOM SET WorkcenterNumber = 40600425 WHERE (SerialNumberProfile <> '') AND (WorkcenterNumber = '') AND (MachineMasterPK = ViewState("MachineMasterPK") & ")" ConnectionAlpha.ConnectionString = ViewState("ConnectionString") ConnectionAlpha.Open() Try ProductionBOMCommand = New SqlCommand(ProductionBOMCmdText, ConnectionAlpha) Dim ra As Integer = ProductionBOMCommand.ExecuteNonQuery() Catch ex As Exception DisplayAlert("UNEXPECTED ERROR!\nPage: InitiateMachine.aspx\nSubroutine: FixTheBOM\nLine: 2376\nError Message: " & Replace(ex.Message, vbCrLf, "\n") & "\nCommand Text:\n" & ProductionBOMCmdText) End Try ConnectionAlpha.Close()I tried to change all the SQL Connections, have re-booted the SQL server, and went ahead and did the KB fix for .NET 2.0, even though this app uses 1.4. What's going on? The rest of the application works fine. It's just this one page that is now throwing errors. Unfortunately, this is kind of the core of the app, and does literally hundreds of SQL transactions every time it is used. What might be going on? I didn't change all that much... Thanks, Steveo Quote The three most important things in life: God, your family, and the Green Bay Packers -- Not necessarily in that order. Winning is not a sometime thing. You don't win once in a while, you don't do things right once in a while, you do them right all the time. Winning is a habit. Unfortunately, so is losing. -- Vincent T. Lombardi
Administrators PlausiblyDamp Posted March 2, 2007 Administrators Posted March 2, 2007 When you catch the error could you also log ex.ToString() as that would give yu more information regarding the stack trace. Are you closing all you connections properly in your application? Try ... Finally blocks could help here; you might want to check through the SQL admin tool or perfmon how many active connections there are - if there are a large number then this error can occur as the server is possibly running at it's limit. Also - just as an aside : are you really storing the connection string and SQL criteria in the viewstate? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
SteveoAtilla Posted March 2, 2007 Author Posted March 2, 2007 Hey, thanks for the quick reply. To try to get more info, I turned the Catch off and found out where the error is actually triggering. Here is that code: Private Sub CreateResponsesEntries() ' Procedure to copy ALL of the Checklist Questions for the Initiated Production Order into the ' Responses table. Dim ChecklistCmdText As String Dim ChecklistCommand As New SqlCommand Dim QuestionCmdText As String Dim QuestionCommand As New SqlCommand Dim ResponseCmdText As String Dim ResponseCommand As New SqlCommand Dim SecBreak As Integer Dim RespOpt As Integer Dim QuesText As String Dim ChecklistPK As Integer Dim Resp1Optional As Integer Dim Resp2Optional As Integer ' Query to get ALL the Checklist Master Primary Keys for all the Checklists in the Checklsit Status ' table for this Machine Master ChecklistCmdText = "SELECT ChecklistMasterPK FROM dbo.ChecklistStatus WHERE MachineMasterPK = " & ViewState("MachineMasterPK") ConnectionZeta.ConnectionString = ViewState("ConnectionString") ConnectionZeta.Open() ChecklistCommand = New SqlCommand(ChecklistCmdText, ConnectionZeta) Dim ChecklistData As SqlDataReader = ChecklistCommand.ExecuteReader(CommandBehavior.CloseConnection) If ChecklistData.HasRows Then ' For each Checklist found for this Production Order, all Questions While ChecklistData.Read ' must be found and copied to the Responses table. ChecklistPK = ChecklistData.GetValue(0) QuestionCmdText = "SELECT ChecklistDetail.QuestionsPK, ChecklistDetail.ResponseType1, ChecklistDetail.ResponseType2, ChecklistDetail.ResponseList1, ChecklistDetail.ResponseList2, ChecklistDetail.LabelText, ChecklistDetail.ChecklistPK, ChecklistDetail.Image, ChecklistDetail.SortOrder, ChecklistDetail.LabelNumber, ChecklistDetail.SectionBreak, ChecklistDetail.QuestionRevNum, ChecklistDetail.QuestionRevDate, ChecklistDetail.QuestionCreateDate, ChecklistDetail.QuestionRevisedDate, ChecklistDetail.ResponseOptional, BinderDetail.WorkcenterPK, ChecklistDetail.AddlResp1Optional, ChecklistDetail.AddlResp2Optional FROM ChecklistDetail INNER JOIN BinderDetail ON ChecklistDetail.ChecklistPK = BinderDetail.ChecklistPK WHERE (ChecklistDetail.ChecklistPK = " & ChecklistPK & ") ORDER BY ChecklistDetail.SortOrder" ConnectionTheta.ConnectionString = ViewState("ConnectionString") ConnectionTheta.Open() QuestionCommand = New SqlCommand(QuestionCmdText, ConnectionTheta) Dim QuestionData As SqlDataReader = QuestionCommand.ExecuteReader(CommandBehavior.Default) If QuestionData.HasRows Then ' If there are any Questions for this Checklist... While QuestionData.Read QuesText = Replace(Replace(QuestionData.GetValue(5), """", "``"), "'", "`") If IsDBNull(QuestionData.GetValue(10)) Then SecBreak = 0 ElseIf QuestionData.GetValue(10) = True Then SecBreak = 1 Else SecBreak = 0 End If If IsDBNull(QuestionData.GetValue(15)) Then RespOpt = 0 ElseIf QuestionData.GetValue(15) = True Then RespOpt = 1 Else RespOpt = 0 End If If IsDBNull(QuestionData.GetValue(17)) Then Resp1Optional = 1 ElseIf QuestionData.GetValue(17) Then Resp1Optional = 1 Else Resp1Optional = 0 End If If IsDBNull(QuestionData.GetValue(18)) Then Resp2Optional = 1 ElseIf QuestionData.GetValue(18) Then Resp2Optional = 1 Else Resp2Optional = 0 End If ' Query to Insert all the Details for this Question into the Responses table... ResponseCmdText = "INSERT INTO dbo.Responses (ProductionOrderPK, WorkCenterPK, QuestionPK, ResponseCheck, ResponseType1, ResponseType2, ResponseList1, ResponseList2, LabelText, ChecklistPK, Image, SortOrder, LabelNumber, SectionBreak, QuestionRevNum, QuestionRevDate, QuestionCreateDate, QuestionRevisedDate, ResponseOptional, AddlResp1Optional, AddlResp2Optional) VALUES (" & ViewState("MachineMasterPK") & ", '" & QuestionData.GetValue(16) & "', '" & QuestionData.GetValue(0) & "', '" & "-1', '" & QuestionData.GetValue(1) & "', '" & QuestionData.GetValue(2) & "', '" & QuestionData.GetValue(3) & "', '" & QuestionData.GetValue(4) & "', '" & QuesText & "', " & QuestionData.GetValue(6) & ", '" & QuestionData.GetValue(7) & "', '" & QuestionData.GetValue(8) & "', '" & QuestionData.GetValue(9) & "', '" & SecBreak & "', '" & QuestionData.GetValue(11) & "', '" & QuestionData.GetValue(12) & "', '" & QuestionData.GetValue(13) & "', '" & QuestionData.GetValue(14) & "', '" & RespOpt & "', '" & Resp1Optional & "', '" & Resp2Optional & "')" ConnectionGamma.ConnectionString = ViewState("ConnectionString") ConnectionGamma.Open() Try ResponseCommand = New SqlCommand(ResponseCmdText, ConnectionGamma) Dim ra As Integer = ResponseCommand.ExecuteNonQuery() Catch ex As Exception DisplayAlert("UNEXPECTED ERROR!\nPage: InitiateMachine.aspx\nSubroutine: CreateResponsesEntries\nLine: 2046\nError Message: " & Replace(ex.Message, vbCrLf, "\n") & "\nCommand Text:\n" & ResponseCmdText) End Try ConnectionGamma.Close() End While End If QuestionData.Close() ConnectionTheta.Close() CreateHeaderQuestions(ChecklistPK) ' Call the Procedure to get the Checklist Header End While ' Questions for this Checklist End If ChecklistData.Close() ConnectionZeta.Close() End SubAnd here's the error stack trace: Internal connection fatal error. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: Internal connection fatal error. Source Error: Line 2057: End If Line 2058: Line 2059: QuestionData.Close() Line 2060: ConnectionTheta.Close() Line 2061: Source File: c:\inetpub\wwwroot\PMTravelBinder\InitiateMachine.aspx.vb Line: 2059 Stack Trace: [invalidOperationException: Internal connection fatal error.] System.Data.SqlClient.SqlDataReader.InternalClose(Boolean closeReader) System.Data.SqlClient.SqlDataReader.Close() PMTravelBinder.InitiateMachine.CreateResponsesEntries() in c:\inetpub\wwwroot\PMTravelBinder\InitiateMachine.aspx.vb:2059 PMTravelBinder.InitiateMachine.btnPost_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\PMTravelBinder\InitiateMachine.aspx.vb:1576 System.Web.UI.WebControls.Button.OnClick(EventArgs e) System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) System.Web.UI.Page.ProcessRequestMain()Does this shed any additional light? Thanks! Steveo Quote The three most important things in life: God, your family, and the Green Bay Packers -- Not necessarily in that order. Winning is not a sometime thing. You don't win once in a while, you don't do things right once in a while, you do them right all the time. Winning is a habit. Unfortunately, so is losing. -- Vincent T. Lombardi
SteveoAtilla Posted March 2, 2007 Author Posted March 2, 2007 Damp, Yeah, I'm really storing the SQL connection string in a ViewState. It's strictly an internal app with no exposure to the outside. Steveo Quote The three most important things in life: God, your family, and the Green Bay Packers -- Not necessarily in that order. Winning is not a sometime thing. You don't win once in a while, you don't do things right once in a while, you do them right all the time. Winning is a habit. Unfortunately, so is losing. -- Vincent T. Lombardi
Administrators PlausiblyDamp Posted March 2, 2007 Administrators Posted March 2, 2007 Looks like it is a problem inside their code rather than yours - did you check to see if you were leaving connections open? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
SteveoAtilla Posted March 2, 2007 Author Posted March 2, 2007 I've checked all the code for unclosed connections, but will do so again. Whose code is "their" code? Can't figure out your reference.... Steveo Quote The three most important things in life: God, your family, and the Green Bay Packers -- Not necessarily in that order. Winning is not a sometime thing. You don't win once in a while, you don't do things right once in a while, you do them right all the time. Winning is a habit. Unfortunately, so is losing. -- Vincent T. Lombardi
Administrators PlausiblyDamp Posted March 2, 2007 Administrators Posted March 2, 2007 The error appears to be being thrown by Microsoft's code - it is an error inside the SQlDataReader class itself - this is either a problem with the DataReader or with the connection to SQL itself. As well as checking you are closing all connections you really should monitor it with a 3rd party tool - this will show what is actually happening rather than what the code suggests is happening. There is always the possibility that readers / connections are not being closed if errors occur as your close statements are outside of the try block. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.