Application Tracing and Error Handling. Catching Exceptions with TRY … CATCH Sub Page_Load Dim conNorthwind As SqlConnection Dim cmdSelect As SqlCommand.

Slides:



Advertisements
Similar presentations
C# Programming: From Problem Analysis to Program Design1 Debugging and Handling Exceptions C# Programming: From Problem Analysis to Program Design 3 rd.
Advertisements

Chapter 11 Debugging and Handling Exceptions
By Sam Nasr, MCP May 22,
11 ASP.NET Controls II Beginning ASP.NET 4.0 in C# 2010 Chapter 6.
It’s Anybody’s Guess Welcome to. Question 1: B. C. D. A. Next question.
Working with ASP Pages. Slide 2 The Tag (1) Remember that most ASP.NET pages contain a single tag with the runat attribute set It’s possible to have multiple.
Web Development in Microsoft Visual Studio Slide 2 Lecture Overview Introduce Visual Studio 2013 Create a first ASP.NET application.
IT533 Lectures Configuring, Deploying, Tracing and Error Handling.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
Tracing, Logging, and Error Handling MacDonald Ch. 8 MIS 424 MIS 424 Professor Sandvig Professor Sandvig.
ASP.NET Programming with C# and SQL Server First Edition Chapter 6 Debugging and Error Handling.
Beginning Web Site Development Module 1 – Dynamic Web Site Development Fundamentals of building dynamic Web sites with ASP.NET 2.0 and C# Version.
11 Updating a Database Table Textbook Chapter 14.
ASP Hello, world. ServerClient Response Request A form.
© Minder Chen, ASP.NET 2.0: Introduction - 1 ASP.NET 2.0 Minder Chen, Ph.D. Framework Base Class Library ADO.NET: Data & XML.
Creating Custom Controls with User Controls. Including Standard Content with User Controls Global Super Company Global Super Company We mean business!
ASP.NET Event Handlers Database -> Browser ->Shopping Basket Validators.
Debugging in Java. Common Bugs Compilation or syntactical errors are the first that you will encounter and the easiest to debug They are usually the result.
1 CS 3870/CS 5870 Note04 Session Variables and Post Back.
Module 2: Connecting to Data Sources. Overview Choosing a.NET Data Provider Defining a Connection Managing a Connection Handling Connection Exceptions.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
1 CS 3870/CS 5870: Note 07 Lab 3 Lab 4 Test 1: Two Tables.
ADO.NET Objects – Data Providers Dr. Ron Eaglin. Requirements Visual Studio 2005 Microsoft SQL Server 2000 or 2005 –Adventure Works Database Installed.
FT228/3 Web Development Error processing. Introduction READ Chapter 9 of Java Server Pages from O’reilly 2 nd Edition Need to be able to 1) Diagnose and.
Sending . Microsoft SMTP Service Simple Mail Transport Protocol Does not support the Post Office Protocol (POP) InetPub\MailRoot\Pickup InetPub\MailRoot\Drop.
Christopher M. Pascucci.NET Programming: WebForm Events.
1 CS387/CS587: Note 08 Shopping Bag DataTable. 2 DataClass Public Shared Function NewShoppingBag() As Data.DataTable Dim bag As New Data.DataTable bag.Columns.Add("Product.
VAT Calculator program Controls Properties Code Results.
1 CS387/CS587: Note05 Lab 3. 2 Global.asax Must not be under any sub-folder Application_Start Application_End Application_Error Session_Start Session_End.
Web Application Development Introduction. Lesson: Creating Web Forms What is a Web Form? Creating a Web Form with Visual Studio.NET.
Created by Alia Al-Abdulkarim 2008 Visual Basic Vs. Java.
Working With ASP.NET Application. Create a new virtual directory The procedure to create a new virtual directory Internet Services Manager Right click.
1 CS 3870/CS 5870: Note 16 Web User Controls. Prog 7 Copy Prog6 to Prog7 Modify all files for Prog7 Remove Web.config from sub-folders Make sure Prog7.
1 CS 3870/CS 5870: Note 13 Web Service. 2 What is Web Service? Providing functionality online to other Web applications SOAP Simple Object Access Protocol.
110 E-1 Variables, Constants and Calculations(2) Chapter 3: Operations on variables, scope of a variable, formatting data Doing Arithmetic.
CIS 375—Web App Dev II ASP.NET 5 Events. 2 The Page_Load Event The Page_Load event is triggered when a page loads. [Example]Example Sub Page_Load lbl1.Text="The.
Debug in Visual Studio Windows Development Fundamentals LESSON 2.5A.
1111 Creating ASPX Controls Programatically Objectives You will be able to Dynamically add controls to a page. Dynamically alter properties of controls.
CHAPTER 10 ERROR HANDLING & DEBUGGING JavaScript can be hard to learn. Everyone makes mistakes when writing it.
Visual Basic. The Close Method The Close method is used to close a form. To close a form use the keyword Me to refer to the form. Me.Close()
Event Handling & Viewstate CS 351 Ed Gellenbeck. Today Review of Web Forms ASP.NET Object Hierarchy Events State Management Page State Session State Application.
C# Exceptions 1 CNS 3260 C#.NET Software Development.
Introduction to ASP.NET, Second Edition2 Chapter Objectives.
Lecture 11 Dr. Eng. Ibrahim El-Nahry Exception Handling.
Visual Basic Fundamental Concepts
Validation & Rich Controls
Computing with C# and the .NET Framework
CS 3870/CS 5870 Web Service.
A variable is a name for a value stored in memory.
Debugging and Handling Exceptions
CS 3870/CS 5870 Web User Controls.
Session Variables and Post Back
CS 3870/CS 5870 AJAX Prog8.
Exception Handling.
Test Manager Plugin for Trac Part 3/3 Roberto Longobardi
Web Services Introduction
מבוא ל ASP.NET שיעור 1 : מבוא ל ASP.NET מצגת מס' 1
CNS 3260 C# .NET Software Development
Visual Basic..
Department Array in Visual Basic
Back Cover Cover Page Page 1-Triple click in this textbox and enter your information for Page 1 of your book. Page2-Triple click in this textbox and enter.
Introducing ASP.net with Visual Studio Environment
Back Cover Cover Page Page 1-Triple click in this textbox and enter your information for Page 1 of your book. Page2-Triple click in this textbox and enter.
Exception Handling.
E-commerce Applications Development
Adding Record To Your Database
Back Cover Cover Page Page 1-Triple click in this textbox and enter your information for Page 1 of your book. Page2-Triple click in this textbox and enter.
Common Coding Defects.
Validation & Rich Controls
Presentation transcript:

Application Tracing and Error Handling

Catching Exceptions with TRY … CATCH Sub Page_Load Dim conNorthwind As SqlConnection Dim cmdSelect As SqlCommand conNorthwind = New _ SqlConnection( "Server=localhost;UID=sa;pwd=secret;Database=Northwind;Connection _ TimeOut=15" ) cmdSelect = New SqlCommand( "select * from Products", conNorthwind ) Try conNorthwind.Open dgrdProducts.DataSource = cmdSelect.ExecuteReader() dgrdProducts.DataBind() conNorthwind.Close Catch Response.Write( "We're sorry, we are experiencing technical problems..." ) End Try End Sub

Catching Exceptions with TRY … CATCH TryCatch.aspx <asp:DataGrid ID="dgrdProducts" Runat="Server" />

Catching Exceptions with TRY … CATCH Sub Page_Load Dim conNorthwind As SqlConnection Dim cmdSelect As SqlCommand conNorthwind = New SqlConnection( "Server=localhost;UID=sa; _ pwd=secret;Database=Northwind;Connection Timeout=15" ) cmdSelect = New SqlCommand( "select * from Products", conNorthwind ) Try conNorthwind.Open dgrdProducts.DataSource = cmdSelect.ExecuteReader dgrdProducts.DataBind() conNorthwind.Close Catch objException As Exception Response.Write( "We're sorry, we are experiencing technical problems..." ) Response.Write( " " ) Response.Write( " Message: " & objException.Message ) Response.Write( " Source: " & objException.Source ) Response.Write( " Stack Trace: " & objException.StackTrace ) Response.Write( " Target Site: " & objException.TargetSite.Name ) End Try End Sub

Catching Exceptions with TRY … CATCH CatchException.aspx <asp:DataGrid ID="dgrdProducts" Runat="Server" /> Message: Returns a string that represents the error message Source: Returns a string representing the object or application that caused the error StackTrace: Returns a string that represents the methods called immediately before the error occurred TargetSite: Returns a MethodBase object that rerepresents the method that caused the error

Catch Particular Exceptions  SqlException Sub Page_Load Dim conNorthwind As SqlConnection Dim cmdSelect As SqlCommand conNorthwind = New SqlConnection( "Server=localhost;UID=sa;pwd=secret; _ Database=Northwind;Connection TimeOut=15" ) cmdSelect = New SqlCommand( "select * from BadTable", conNorthwind ) Try conNorthwind.Open() dgrdProducts.DataSource = cmdSelect.ExecuteReader dgrdProducts.DataBind() conNorthwind.Close Catch objException As SqlException Dim objError As SqlError For each objError in objException.Errors Response.Write( " " & objError.Message ) Next End Try End Sub

Catch Particular Exceptions SqlException.aspx <asp:DataGrid ID="dgrdProducts" Runat="Server" />  SqlException

Catching Unhandled Exceptions in a Page Sub Page_Error Response.Write( "Sorry, there was an error:" ) Response.Write( " " ) Response.Write( Server.GetLastError.Message ) Server.ClearError() End Sub Sub Page_Load Dim txtTextBox As TextBox txtTextBox.Text = "Hello World!" End Sub PageError.aspx This page contains an error!

Tracing and Monitoring Your Application Sub Page_Load Trace.Warn( "Page Loading" ) End Sub Sub Button_Click( s As Object, e As EventArgs ) Trace.Warn( "The value of favColor is " & txtFavColor.Text ) lblMessage.Text = "Button Clicked!" End Sub Trace.aspx Enter your Favorite Color Favorite Color: <asp:TextBox ID="txtFavColor" Runat="Server" /> <asp:Button Text="Click Here!" OnClick="Button_Click" Runat="Server" /> <asp:Label ID="lblMessage" Runat="Server" />

Using the Debugger  Web.Config

Using the Debugger Sub Page_Load Dim intcounter As Integer For intCounter = 0 to 10 lblCount.Text = intCounter.ToString() Next End Sub DebugThis.aspx <asp:Label id="lblCount" Runat="Server" /> Create a break point