ASP.Net

Formatting Dates

I was having a lot of code that looked like the following:          if(dr["StartTime"] != DBNull.Value)                    tbStartTime.Text = dr["StartTime"].ToString("M/d/yy H:mm");          else               tbStartTime.Text = ""; and:          tbStartTime.Text = DateTime.Now.ToString("M/d/yy H:mm");   You usually use the same formatting throughout an application so I simplified

Formatting Dates Read More »

Reporting when Logging only the start and end of an outage condition

In a previous post I had a system to only log the start and end of an outage condition.  To report on the outages we need to first look at the table where the exceptions get logged:     CREATE TABLE [dbo].[Exceptions](         [ExTime] [datetime] NULL CONSTRAINT [DF_Exceptions_ExTime]  DEFAULT (getdate()),        

Reporting when Logging only the start and end of an outage condition Read More »

SET ANSI_NULLS OFF

We found an issue with some of the older scripts having SET ANSI_NULLS OFF and this causes problems.  The ANSI_NULLS ON setting is a database option that determines how NULL comparisons are handled. Under ANSI_NULLS ON, two NULL values will never be equal to each other because the two separate values are unknown. With ANSI_NULLS

SET ANSI_NULLS OFF Read More »

GridView Sort Column Arrow Performance

I see code like the following a lot: protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) {      if (e.Row.RowType == DataControlRowType.Header)             if (String.Empty != this.GridView1.SortExpression)                        AddSortImage(e.Row);                          } The problem with this is that it fires for each row in the GridView slowing performance.  A better way is the following which only fires once

GridView Sort Column Arrow Performance Read More »

Connection Pool Misconceptions

Below is the sql to show how many connection are being used from my application. declare @Database varchar(30),     @LoginName varchar(30) set @Database = 'MyDB' set @LoginName = 'MyLoginName' select max(blocked) hasBlocking,     count(1) [Count],     sum(open_tran) open_trans,     max(waittime) maxWaitTime from master.dbo.sysprocesses (nolock) where db_name(dbid) = @Database and convert(sysname, rtrim(loginame)) = @LoginName          We

Connection Pool Misconceptions Read More »