My tech blog and other writing

Thursday, August 31, 2006

Training list

I have a larger project comming up and will take a week or two before it begins to do some self-training in preparation for it. Here is a list of topics:
  1. CSLA
  2. Enterprise Library (specifially but not limited to Exception Handling)
  3. NUnit/NUnit.asp and TestDriven.net
  4. SQL Server 2005 new features
  5. ASP.net components/master pages

Monday, August 28, 2006

UltraEdit rocks

I finally broke down and bought a copy of UltraEdit for my home PC. I have become so accustom to using it at work that I bought I copy for home.

UltraEdit.com

Tuesday, August 22, 2006

classic ASP & SQL 2005

I guess by default the only protocol turned on for SQL 2005 is "shared memory." So if you have a connection string with...

PROVIDER=SQLOLEDB


It will fail... with the following error...

Error Type:
Microsoft OLE DB Provider for SQL Server (0x80004005)
[DBNETLIB][ConnectionOpen (ParseConnectParams()).]Invalid connection.


So you have two choices. 1.) Enable TCP/IP for the SQL Server; OR 2.) don't use SQLOLEDB which uses TCP/IP use SQLNCLI. or PROVIDER=SQLNCLI

Note to enable TCP/IP you use the SQL Server Configruation Manager which is one of the Configuration tools...

Tuesday, August 15, 2006

Nice article on the singleton pattern

http://www.yoda.arachsys.com/csharp/singleton.html

aslo check out http://www.yoda.arachsys.com/csharp/beforefieldinit.html

Here is some code you can use to test the fourth version presented... I think this implimentation is very neat and the pattern is very neat (keeps code clean). I like the way it is implimented and believe the runtime rules ensure it is thread safe but I will trust the author in this case...
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace Singleton1test
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Console.WriteLine("begin " + DateTime.Now.ToString());
            Singleton s = Singleton.Instance;
            Console.WriteLine("test " + s.now);
           
            Thread.Sleep(2000);

            Singleton s2 = Singleton.Instance;
            System.Console.WriteLine("second test " + DateTime.Now.ToString());
            Console.WriteLine("test " + s2.now);

            Thread.Sleep(2000);

            Singleton s3 = Singleton.Instance;
            System.Console.WriteLine("Third test " + DateTime.Now.ToString());
            Console.WriteLine("test " + s3.now);


            while (Console.ReadLine() == "asl;difasldfljasdf" ) { }
        }
    }


    public sealed class Singleton
    {
        static readonly Singleton instance = new Singleton();

        private string somedatestring;

        // Explicit static constructor to tell C# compiler
        // not to mark type as beforefieldinit
        static Singleton()
        {
            Console.WriteLine("In static Constructor");
        }

        Singleton()
        {
            Console.WriteLine("In non-static Constructor");
            somedatestring = DateTime.Now.ToString();
        }

        public static Singleton Instance
        {
            get
            {
                return instance;
            }
        }

        public string now
        {
            get
            {
                return somedatestring;
            }
        }
    }


}