11 Feb 2008

How To: Change Instance Name Of SQL Server

27 Comments Uncategorized

Recently I change the network name of one of my servers at work, because the box changed its job from a virtual machine server to the database server. Everything was going great until I decided to setup the server for replication and received the following error message.

New Publication Wizard
——————————

SQL Server replication requires the actual server name to make a connection to the server. Connections through a server alias, IP address, or any other alternate name are not supported. Specify the actual server name, ‘old_name’. (Replication.Utilities)

——————————
OK
——————————

So with a little hunting and SQL queries I found out that SQL Server doesn’t use the network name, it only excepts that as an alias. My SQL Server instance was still named “old_name”. I found that out by running these two queries:

sp_helpserver
select @@servername

So in order to get the network name and the SQL Server instance name back in sync I had do these steps:

  1. Run this in Microsoft SQL Server Management Studio:
    sp_dropserver 'old_name'
    go
    sp_addserver 'new_name','local'
    go
  2. Restart SQL Server service. I prefer the command prompt for this, but you can just as easily do it in Services under the Control Panel
    net stop mssqlserver
    net start mssqlserver

Then after that is done run this again, to make sure everything is changed:

sp_helpserver
select @@servername

I don’t understand why SQL Server uses it’s own name versus the network name, might be due to the fact you can have multiple SQL Server instances install on one machine. It wasn’t too hard to change and probably stems from the days when SQL Server was known as Sybase, all in all, I learned something new and it only took 30 minutes of my day to fine the answer.

03 Feb 2008

Does anybody have a name for this programming pattern?

No Comments Uncategorized

Recently I have been working very hard on getting a new Web 2.0 initiative off the ground. With most new initiatives I like to start out by looking for software development patterns that will help me standardize my structure as well as make the programming experience common for any new members that are brought on the team. However I recently ran in to a structural “pattern” that seems like it is pretty simple and it addresses a common problem in software development. I researched as much as possible on all the common pattern websites that I visit and even went as far as posting on ASP.NET Forums to see if anybody could help me, give it a name. If this “pattern” hasn’t been named yet I am going to be shocked.

I like to consider myself pretty educated when it comes to some of the recent developments in structured software development. However I am at a total loss here so I am presenting this pattern to my readers to see if they have seen it before? For now I am calling this “The Modeling Pattern”:

The pattern I had in mind is to have the same object with different interfaces each modeling the required data for a specific type of User Interface.

In many websites you normally have the same information represented in various different ways. I originally arrived at this pattern after listening to Scott Hanselman’s MVC Screencast. The idea of a model, as in the M in the Model View Controller (MVC), really intrigued me. The more I thought about standard web page designs and how they are mostly based around only one “object”, the more it convinced me I was using the right model. For example you have these two different views of a article on the .NET Kicks site. (Which is a great site by the way.)

.NET Kicks Article Card

I call this a card just for the fact that it is a small representation of all the information for this article, much like a business card is a small representation of all the information about a person.
.NET Kicks Article Card

.NET Kicks Article

.NET Kicks Article

Notice how most of the information is similar between the two images above. We know they are similar because it is the same information represented from the database in different views. However the main difference is the amount of information show. Obviously it would be a massive overkill to load the users who kicked the story, and comments, when all that is required is the card view for the front page. I imagine most of this is not new to many of my readers, because SQL lets you create your datasets (models) however you want at will, the real trick in software development is creating the finite number of objects for the infinite number of datasets that SQL can return. That is what I am trying to address with “The Modeling Pattern”, creating a finite number of objects that makes sense based on the views I need for my application, because you obviously don’t want to dirty load all the properties for performance reasons. This is how I would code the above in “The Modeling Pattern”.

interface IUserModel
{
	int Id { get; set; }
	string UserName { get; set; }
	DateTime JoinedOn { get; set; }
}

interface IArticleCardModel
{
	int Id { get; set; }
	string Name { get; set; }
	string Description { get; set; }
	int KickCount ( get; set; }
	int CommentCount ( get; set; }
	void Kick (IUserModel user);
}

interface IArticleModel : IArticleCard
{
	List<string> Comments { get; }
	List<IUserModel> UserKicks { get; }
}

Then with these interfaces you create the objects.

class User : IUserModel
{
	// implement interfaces plus supporting code
}

class Article : IArticleModel, IArticleCardModel
{
	// implement interfaces plus supporting code
}

Then you create a helper class to fill these methods in the data layer.

static class DataHelper
{
	public static IArticleCardModel GetArticle (int id)
	{
		IArticleCardModel a = new Article();
		// get data from database and only fill in IArticleCardModel interfaces
	}

	public static IArticleModel GetArticle (int id)
	{
		IArticleModel a = new Article();
		// get data from database and fill in IArticleModel interfaces
		// including supporting tables such as the collections
		// or fill in some and dirty fill the others
	}

	// do the same for User
}

To use this pattern in something like the MVC framework, you would just use the interfaces instead of the actual object. What this does for you is two fold. Defines the UI model that is required and because it is an interface it doesn’t allow you access to the other properties of the class that maybe null.

So if anybody has seen this pattern before I would love to here about it. Also if you have a better name for it and you haven’t heard of it, I would love it to have something more than the tactical “The Modeling Pattern”.

01 Oct 2007

Anything For Sale By Owner

1 Comment Uncategorized

Anything For Sale By Owner LogoAs I alluded in a post a couple of weeks ago, I have been a bad blogger. And I have neglected my community of readers. However I would like to tell you what I have been doing in the last couple of months while I have been neglecting my blog.

I recently got involved in creating a startup as the lead developer for an online classifieds site called Anything For Sale By Owner. From the ground up this was conceived as a middle-ground between craigslist and ebay where every listing would be charged at a static rate of $1.00/month. The $1.00 is a way to week out the crap from craigslist and the death-by-fees from ebay.

The description is pretty straight forward but the more interesting tid-bits that I know my readers are interested in are as follows:

.NET/C#

We choose .NET mostly because it is what I knew and .NET for me has always been stable, predictable, and performed really well on server-side applications. The alternative was PHP and even through we wrote many of the processing layers by our self (i.e. REST Web Service Handler) the time to deployment was greatly accelerated because of all the work the Microsoft ASP.NET Team has put in to the product. The user of Master Pages and Web Services made for an easy separation between content and display.

MySQL

We choose MySQL for a whole host of reasons mostly based around the costs associated with a single Microsoft SQL Server Standard Edition license. Other reasons we choose MySQL was for scalability, because not only could we install 5 database servers (hardware included) for the same price we could purchase 1 MSSQL database server for but also because the master/slave replication of the databases seemed to be an easier process when we needed to scale horizontally.

REST Web Services/AJAX

We followed the Digg Model for exposing web services and each web service could be changed around to provide output through JSON, RSS, ATOM, KML (where applicable), and XML. I even did a write up about a month ago on the JSON Serializer that I developed for this website. This was very important for the AJAX we needed to control many aspects of the user experience.

Open Search

Open search was one of the value add features that wasn’t in the original spec but was an easy add-on because we already had the Web Services in place to leverage. You can view our open search XML definition file here. If you are unfamiliar with Open Search this is how A9.com defines it:

OpenSearch is a set of simple formats for the sharing of search results. Any website that has a search feature can make their results available in OpenSearch format. Other tools can then read those search results.

So that little search box in the upper right hand corner of your browser is an example of an Open Search client.

SEO

Search Engine Optimization is a very important part of any website today. Because for most new sites and even some of the older ones, Google is going to be the largest most ignored user of the site. Not only will Google look at every single page on your site every week, which I dare any human to try and accomplish, they will also be the largest organic promoter of your site.

One of the corner stones of SEO is easily readable URL’s that contain descriptive keywords. This means you have to have a good URL Rewriter in place. We choose Ionic’s ISAPI Rewriter that integrated nicely with IIS 6.0. However that left a big gap between using Visual Studio’s Intigrated Web Server (which doesn’t support ISAPI) and a full blown IIS Server. The benifits are pretty obvious for running the Intigrated Web Server that comes with Visual Studio, for one you don’t always have to have IIS that comes with Windows XP always running and the host of security problems that comes with it, two I was running Windows Vista and IIS 7.0 has some huge differences from IIS 6.0.

So I sat down one night and wrote my own Apache mod_rewrite compatible HttpModule for running the same rule-set that I defined for Ionic’s ISAPI Rewriter, to fill in the gap and make developing on my local machine as close as running the live web site on IIS 6.0.

If anybody is interested I offer the Url Rrewriter as a free download:

Front End Design

I am a software developer and usually don’t get invovled in the artsy end of the web site design. So I will let my co-worker Tom Lauck describe how he developed the front-end for Anything For Sale By Owner.

So all in all I believe that this website has a very good chance of making in the Wild Wild West that the Internet is, however that is probably just the ramblings of a proud father. Be on the look out for some major marketing campaigns in the NYC Times Square region.