I have this code that I know is getting hit, because the insert is being accomplished:
Response.Write("<!-- Made it just before INSERT INTO CustomerCategoryLog -->")
Dim query As String = String.Empty
query &= "INSERT INTO CustomerCategoryLog (MemberNo, Unit, Custno, "
query &= "Category, Subcategory, BeginDate, "
query &= "EndDate, ChangedBy, ChangedOn) "
query &= "VALUES (@MemberNo, @Unit, @Custno, @Category, @Subcategory, @BeginDate, @EndDate, @ChangedBy, @ChangedOn)"
Using conn As New SqlConnection("SERVER=PROSQL05;DATABASE=cpsdata;UID=sa;PWD=sqlsql")
Using comm As New SqlCommand()
Response.Write("<!-- Made it into the using comm As New SqlCommand() block -->")
With comm
.Connection = conn
.CommandType = CommandType.Text
.CommandText = query
.Parameters.Add("@MemberNo", SqlDbType.NVarChar).Value = MemberNo
.Parameters.Add("@Unit", SqlDbType.NVarChar).Value = Unit
.Parameters.Add("@Custno", SqlDbType.NVarChar).Value = CustNo
.Parameters.Add("@Category", SqlDbType.NVarChar).Value = Category
.Parameters.Add("@Subcategory", SqlDbType.NVarChar).Value = Subcategory
.Parameters.Add("@BeginDate", SqlDbType.DateTime).Value = Date.Now()
.Parameters.Add("@EndDate", SqlDbType.DateTime).Value = Date.Now().AddDays(365)
.Parameters.Add("@ChangedBy", SqlDbType.NVarChar).Value = Environment.UserName
.Parameters.Add("@ChangedOn", SqlDbType.DateTime).Value = Date.Now()
End With
Try
Response.Write("<!-- Made it into the try block -->")
conn.Open()
comm.ExecuteNonQuery()
Catch '(ex as SqlException)
Response.Write("<!-- Made it into the catch block -->")
End Try
End Using 'comm
End Using 'conn
Yet none of the Response.Write()s are get rendered to the page, as "View Source" shows.
Why aren't they? In a previous place, a comment/debug msg is getting written, using the same syntax:
Response.Write("<!-- IsNewBusiness after NOT adoRS.EOF check = " & CStr(IsNewBusiness) & " -->")
Why do subsequent calls to Response.Write() do nothing?
UPDATE
There is a "system.diagnostics" section in Web.Config, with this content:
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog" />
<!-- Uncomment the below section to write to the Application Event Log -->
<add name="EventLog" />
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter" />
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="eServices" />
</sharedListeners>
</system.diagnostics>
As you can see, there is a "sharedListeners" subsection, but as far as I can tell, it's not clearing them...
UPDATE 2
This is what I get after prepending "HttpContext.ApplicationInstance.Context." to "Trace.Write(":
Server Error in '/EMS/customerreportingnet' Application.
--------------------------------------------------------------------------------
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30469: Reference to a non-shared member requires an object reference.
Source Error:
Line 184: ' Put the Category Table insert here, too...
Line 185: ' Beginning of SQL Insert code added 3/6/2017 - if not reached, move it above the "END IF"
Line 186: HttpContext.ApplicationInstance.Context.Trace.Write("<!-- Made it just before INSERT INTO CustomerCategoryLog -->")
Line 187: Dim query As String = String.Empty
Line 188: query &= "INSERT INTO CustomerCategoryLog (MemberNo, Unit, Custno, "
Source File: C:\EnhancedMonthlySalesReporting\customerreportingnet\customerreportingnet\pages\custmaint_entry.aspx Line: 186
UDPATE 3
A (very, to me) strange thing is that when I got trace.axd, it does not list the file in question - the one into which I have inserted the calls to Trace.axd:
but I am on that page (though it doesn't show in the URL, which remainshttp://localhost/EMS/customerreportingnet), when I append the "/trace.axd" to the URL and hit the Enter key.
Why would the file not appear in the list?
If I "View Source" from that page, I do see some of its output, such as ""
So custmaint_entry.aspx is being accessed - which is also seen by the URL in the "View Source" pane: