Asp.Net > Code Snippets
Error Loging in ASP.NET
Error Loging in ASP.NET Run this code to create table : if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[errorLog]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[errorLog] GO CREATE TABLE [dbo].[errorLog] ( [errID] [int] IDENTITY (1, 1) NOT NULL , [errorPage] [nvarchar] (150) , [errorDate] [datetime] NULL ) ON [PRIMARY] GO Now we will create our stored procedure : CREATE PROCEDURE dbo.insertLog @page NVARCHAR(150) AS BEGIN INSERT ErrorLog ( errorPage, errorDate ) VALUES ( @page, GETDATE() ) END GO Now if doed not exist web.config file create one or modify it with those codes :
Ok. Our hard work finished after modifying our database connection. Double check that you have run sql scripts correctly without any error. You may use SQL Query Analyzer. Do not miss to check SQL connection. After editing and upload this script to your site. <%@ Page Language="VB" Debug="true" %> <%@ import namespace="System.Data" %> <%@ import namespace="System.Data.SQLClient" %> <%@ import namespace="System.Diagnostics" %>
Sorry, A error has occurred in this page.
Asp Codes
ActiveX
ADO
Array
Code Snippets
Components
Data Access
Date Time
Files
Graphics
HTML Formatting
Mathematics
Miscellaneous
Sessions
SQL
Strings
Techniques
XML