Great Cartoon!
By · CommentsSomeone at the office sent this to me. I don’t know where it came from but it made me laugh!
Spam where art thou?
By · Comments“Spam will be a thing of the past in two years’ time.” Bill Gates, BBC News, 2004
Bill Gates might not have actually said the quote about 640k RAM being enough for anyone, but he did say the above statement. Too bad it didn’t prove true.
SQL Work Table Woes
By · CommentsOne of our premiere clients has an online store that we created for them using MS Commerce Server. The client’s ERP system is the system of record for product data and the orders placed online. Our MCSC (Commerce Server) web application interfaces with the source system through a set of stored procedures that were created by and are maintained by another vendor. The “real” source system is in California while the web app is hosted by us in Florida. When web app was first deigned the other vendor recommended to the client that a local copy of the source database be created in Florida and they would synch the 2 systems through a proprietary mechanism they had developed. Our web application calls the aforementioned stored procedures to synch MSCS with the source data. We are bringing in product data inventory, pricing,etc. From the beginning there have been issues with the synching of data. These issues were intermittent and not a very big problem.
Now the system has grown considerably and there have been many new processes added that retrieve data from the 3rd party stored procedures. The number of hits on the web application has also grown considerably. Today this little problem has become a nightmare. BUT I found the culprit.
Finding a file in TFS
By · CommentsNeed to find a file in your TFS server? Don’t know what project a particular file is located in? Here’s how you can find a file in TFS using the command line tool. Read More→
Find a String Between 2 Strings
By · CommentsHere’s a way to return a substring of string that is between 2 strings in C#. There are other options for doing this, such as RegEx, but this is clean and simple.
// This search returns the substring between two strings, so // the first index is moved to the character just after the first string. int first = str.IndexOf("$string1$") + "$string1$".Length; int last = str.LastIndexOf("$string2$"); string str2 = str.Substring(first, last - first);
Restore SQL Database
By · CommentsRestoring a SQL Server database from a backup is easy to accomplish in the SQL Server IDE. Well, sometimes. In the real world, I often need to restore a development database, but the restore fails because I cannot gain exclusive access to the database. Some developers will detach the database and reattach it to grab exclusive access. If there are processes running frequently against the database, that may not work. Neither will killing all connections always work. The solution I’ve found is a short snippet of SQL to grab exclusive access, do the restore and then restore multi-user access. It looks like this:
USE master — Must be connected to a different database
-- Get exclusive access ALTER DATABASE XXXXXX_Stage SET SINGLE_USER WITH ROLLBACK IMMEDIATE; -- Restore from disk -- Note WITH REPLACE http://msdn.microsoft.com/en-us/library/ms178615.aspx RESTORE DATABASE XXXXXX_Stage FROM DISK = 'F:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\XXXXXX_Stage _20100505.bak' WITH REPLACE -- Restore multi user access ALTER DATABASE XXXXXX_Stage SET MULTI_USER WITH ROLLBACK IMMEDIATE;
Note the WITH ROLLBACK clauses. You should take a production database down and make sure all transactions have completed. Then do a restore through the IDE. If you use the code above, you may lose some transactions or logs. This usually doesn’t matter in a test environment.
Have fun!
Technorati Tags: SQL Server,SQL,Code Sample,Database,Server,backup
Snippet Designed for VS 2008 and VS 2010
By · CommentsI love code snippets. Way back in the early VB days, I created add-ins for the IDE that allowed me to create and save an array of short snippets of code and automatically insert them into the code window. I like to use snippets for things that I either don’t use often enough to remember, or to quickly enter templates for things I use a lot to save time. Visual Studio .Net has a Snippet Manager and lets you create snippets in XML, but there is no built-in editor. There are a couple of editors available, some stand-alone and at least one called Snippet Designer that is integrated into the IDE. Read More→
Create Singleton in C#
By · CommentsOne of the most basic and most useful object patterns is the Singleton design pattern. A Singleton is a class of which there will only be one instance created at any time. All users of the Singleton class will all use the same instance. This is great for a wide range of applications such as cached values and lookups or utilities that execute quickly. The Design Patterns book by Gamma et al . describes the structure of a basic Singleton. We’ll describe how to create one in C#.
Title Case in C#
By · CommentsHere a quick snippet to convert text to Title Case in C# that uses the TextInfo class. Note that strings with all caps will not be converted, so convert to lower case first.
// Defines the string with mixed casing.
string myString = "this iS a StrIng with MIXED CaSe";
// Create a TextInfo based on the "en-US" culture.
TextInfo tInfo = new CultureInfo("en-US", false).TextInfo;
// Changes a string to titlecase.
// Note the ToLower(), needed to convert words in all caps like MIXED
Console.WriteLine("\"{0}\" to titlecase: {1}", myString, tInfo.ToTitleCase(myString.ToLower()));
//Result: This Is A String With Mixed Case
Console.ReadLine();
// Defines the string with mixed casing.
string myString = “this iS a StrIng with MIXED CaSe”;
// Create a TextInfo based on the “en-US” culture.
TextInfo tInfo = new CultureInfo(“en-US”, false).TextInfo;
// Changes a string to titlecase.
// Note the ToLower(), needed to convert words in all caps like MIXED
Console.WriteLine(“\”{0}\” to titlecase: {1}”, myString, tInfo.ToTitleCase(myString.ToLower()));
//Result: This Is A String With Mixed Case
Console.ReadLine();
Eco-Friendly PC Disposal
By · CommentsWhat do you do with old PCs, cell phones and other e-devices? Staples has an eco-friendly disposal program. Dell products are free as are cell phones and some other devices. Other PCs, laptops cost about $10 US. They also destroy the data on the drives.
Be friendly to the planet when you dispose of old PCs!
http://www.staples.com/sbd/cre/marketing/ecoeasy/index2.html


