Saturday, December 14, 2013

MSDE enable TCP/IP or Named Pipes in SQL Server 2000

When you inherit a new server sometimes you find that you can't connect to the server, to fix that you may need to simply enable the protocol via Sql Server Network Utility (svrnetcn) that is listening For MSDE.
  1. In Windows, click Start and Run.
  2. Enter svrnetcn and click OK.
  3. Under the General tab, verify that the correct instance for the server is displayed in the Instance(s) on this server box.
  4. Highlight your desired protocol and click Enable (double clicking the name also moves the protocol to the enabled protocols box).
  5. Click OK.
  6. Restart the Sql Server Instance
  7. In Windows, click Start and Run.
  8. enter services.msc
  9. Locate the MSSQLSERVER instance you modified in the Sql Server Network Utility and Restart the service.
You may wish to ensure that your users are not logged on or at least notified of this change as it will kick them out of the application
Thanks to sqlthis blog for the content.
http://sqlthis.blogspot.com/2009/04/msde-enable-tcpip-or-named-pipes.html
 

Thursday, December 12, 2013

Implementing .Net ArrayList with Changed event

Sometimes we need a List which can notify user when an item is added. Here is the way that you can implement a generic ArrayList which notifies user at the time of an element is added.

using System;
using System.Collections;
namespace ArchiveData.Logging
{
  // A delegate type for hooking up change notifications.
  public delegate void ChangedEventHandler(object sender, EventArgs e);
  public class ListWithChangedEvent : ArrayList
  {
    // An event that clients can use to be notified whenever the
    // elements of the list change.
    public event ChangedEventHandler Changed;
    public object NewlyAddedItem { getset; }
    // Invoke the Changed event; called whenever list changes
    protected virtual void OnChanged(EventArgs e)
    {
      if (Changed != null)
        Changed(this, e);
    }
    // Override some of the methods that can change the list;
    // invoke event after each
    public override int Add(object value)
    {
      NewlyAddedItem = value;
      var i = base.Add(value);
      OnChanged(EventArgs.Empty);
      return i;
    }
    public override void Clear()
    {
      base.Clear();
      OnChanged(EventArgs.Empty);
    }
    public override object this[int index]
    {
      set
      {
        base[index] = value;
        OnChanged(EventArgs.Empty);
      }
    }
  }
}


I got this from MSDN. I feel that it would be helpful to you all too.

Enjoy!