How to iterate a C# dictionary

The following snippet shows an easy way to iterate a C# dictionary:



            Dictionary<int, string> dictionary = new Dictionary<int, string>();

            dictionary.Add(1, "Cat");
            dictionary.Add(2, "Dog");
            dictionary.Add(3, "Horse");

            foreach (var item in dictionary)
            {
                // do stuff with item
                Console.WriteLine(string.Format("{0} - {1}", item.Key, item.Value));
            }

            // Result:
            // 1 - Cat
            // 2 - Dog
            // 3 - Horse


       

Posted in .NET | Tagged , , | Comments Off

Mercurial and Redmine on Bluehost

Here is how I installed Mercurial and Redmine on bluehost
It is a script/screenshot walktrough on the entire setup.

Posted in bluehost | Tagged , , | Comments Off

How to export your SQL Server table – the easy way

Since I work as a consultant I always bring with me my “toolbox”. My latest addition to this toolbox is a SQL Server script created by Narayana Vyas Kondreddi

He has created a script that let you export your data, by generating a insert script, from a given table in a very easy way.

All you need to do to make is work is:

  • Download the script and add the procedure called sp_generate_inserts
  • Generate your insert script by calling: EXEC sp_generate_inserts ‘myTable’

The insert script will now be written to the output in query analyzer.

Please note that by default the query analyzer will only display the first 256 charachters from each line.
You can change this setting from: Tools->Options->Query Result->SQL Server->Result to Text.

Maximum allowed value is 8192.

You can download the script here: http://vyaskn.tripod.com/code/generate_inserts_2005.txt.

For more information on how to use the script and all the features check out this page: http://vyaskn.tripod.com/code.htm#inserts

Posted in SQL Server | Tagged , , | Comments Off