About Me

My photo
Northglenn, Colorado, United States
I'm primarily a BI Developer on the Microsoft stack. I do sometimes touch upon other Microsoft stacks ( web development, application development, and sql server development).

Wednesday, January 16, 2008

How to make a new command in Windows PowerShell

Lets say you have a idea for a new function that you would like to implement in Window's PowerShell. In this case I made a Unix like whoami command:

function whoami
{
     [System.Security.Principal.WindowsIdentity]::GetCurrent().Name       
}

when in PowerShell it returned for me: mss/wandrus. Simple enough. Now to get the command to be usable every time an new PowerShell is opened.

 

Type within PowerShell:  Get-Variable profile | Format-List

This should give you the information on what file and directory path are needed to place your custom scripts. In this case I was given:

C:\Document and Settings\wandrus\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

 

Which meant that I had to create a new folder (WindowsPowerShell) and a new script file in notepad (Microsoft.PowerShell_profile.ps1) where I've place my function.

Monday, January 14, 2008

Installing SQL Server 2008 - Code name "Katmai"

Well, I finally got around to installing SQL Server 2008. Ran into a little problem when it came to the Server Configuration screen. I got this error

"Invalid or missing username or password. To continue, provide valid credentials for the SQL Server Agent service".

The solution was to use my credentials for the login with username of mss/wandrus and my login password.

 


UPDATED: http://www.sql-articles.com/articles/SQL2008/ins_2008.html
http://www.sql-articles.com/index.php?page=articles/SQL2008/ins_2008.html does a nice job of showing how to step through the installation process.

Tuesday, December 18, 2007

BizTalk Blogs

One way to keep up to date with the new trends and continually learn is to read, read, and then read some more. To soak in Biztalk with the many changes that are happening in this industry, try reading some blogs: http://biztalkblogs.com/

RSS: http://biztalkblogs.com/RssDoc.xml

Spell Checker for your code's comments

Comment Spell Checker

A spell checker for your comments in Visual Studio 2005 and Visual Studio 2008. This is a nice tool, I hate looking stupid because of stupid spelling mistakes. When you build your project(s) the spelling mistakes show up under "Messages" (third tab in the Error List). Brought to you by: http://blogs.msdn.com/webdevtools/archive/2007/12/13/spell-checker-for-html-asp-net-jscript-vb-c-css-and-c-for-visual-studio-2005-and-2008.aspx#comments

Monday, December 17, 2007

Powershell and BizTalk

One of the jobs I hated when doing support was going through the process of stopping and starting services then re-sending data through biztalk. I think with the power of PowerShell, you now can automate all of these tedious tasks into one simple cmdlet. (get-help *-service should be a good start)

Powershell is a really nice feature and I believe anyone that has any basic UNIX/Linux knowledge should be able to pick up the basics real quick.

Wednesday, November 07, 2007

Bug?? Reference variable arrays

A co-worker came to me with this problem:




    1         public static int[] MainArray = new int[2] { 0, 0 };


    2         static void Main(string[] args)


    3         {


    4             GetArray();


    5         }


    6         private static void GetArray()


    7         {


    8             MakeNewArray(MainArray);


    9         }


   10         private static void MakeNewArray(int[] p)


   11         {


   12             p[0] = 1;


   13             Console.WriteLine("p[0]:" + p[0].ToString());


   14             Console.WriteLine("MainArray[0]:" + MainArray[0].ToString());


   15             Console.ReadLine();


   16         }






Result:
p[0]:1
MainArray[0]:1

He wanted a copy version of the integer array, but instead it was acting like it was being reference. The response of the code seems wrong since you would expect it to make a seperate array and not reference the MainArray.

What seems to be happening is that since these are arrays, and of the type Reference. Then the arrays are placed on the heap, with the variable names placed on the stack (some what). So, when making a call to a seperate method, the new variable p is then placed on the stack, but pointing to MainArray's values on the heap. Giving a reference type behavior. The solution is to make a copy of the array.




    1         public static int[] MainArray = new int[2] { 0, 0 };


    2         static void Main(string[] args)


    3         {


    4             GetArray();


    5         }


    6         private static void GetArray()


    7         {


    8             MakeNewArray();


    9         }


   10         private static void MakeNewArray()


   11         {


   12             int[] p = new int[MainArray.Length];


   13             Array.Copy(MainArray, p, MainArray.Length);


   14             p[0] = 1;


   15             Console.WriteLine("p[0]:" + p[0].ToString());


   16             Console.WriteLine("MainArray[0]:" + MainArray[0].ToString());


   17             Console.ReadLine();


   18         }







Result:
p[0]:1
MainArray[0]:0

Tuesday, November 06, 2007

A good .Net Threading tutorial site.

http://www.albahari.com/threading/part2.html

Upgrading from .Net Framework 1.0 to 3.5

  • First upgrade your code from .NET 1.0 to .NET 1.1 using Visual Studio 2003. It has a project upgrade tool with some assistance.

  • Next use Visual Studio 2008 to upgrade the project from .NET 1.1 to .NET 2.0. The upgrade wizard here does not change your code. It will show you warnings for things that you have to change but you will have to go change them. You also have to fix all your new compile errors and do a full retest.

  • Once you're at .NET 2.0 the migration to .NET 3.0 and .NET 3.5 is easy. It's primarily just about using the new features available in these new versions of the framework. All your existing code should work fine, in fact you most likely wont even need to recompile.



The .NET 1.1 -> .NET 2.0 breaking changes are detailed here: http://msdn2.microsoft.com/en-us/netframework/aa570326.aspx

Here's a helpful blog entry from Brad Abrams on upgrade experience:
http://blogs.msdn.com/brada/archive/2007/01/15/real-world-customer-experience-in-migrating-from-net-framework-1-1-to-2-0.aspx

Here's another great post on this topic deom Daniel Moth:http://www.danielmoth.com/Blog/2007/10/migrating-from-net-framework-v1x-to.html

- source: http://blogs.msdn.com/pandrew/archive/2007/10/25/how-to-upgrade-from-net-framework-1-0-to-net-framework-3-5.aspx


So, I guess they make the transition from 1.0 to 3.5 look easy. Just hope I never have to do it. <^_^>

Monday, November 05, 2007

SQL Server 2008 Date and Time data types

No more converting datetimes and combining datetimes together because you wanted to seperate date and time. (EX: '1/1/1900 11:36AM')

Here are the new data types for SQL Server 2008:










































Data typeFormatRangeAccuracy
timehh:mm:ss[.nnnnnnn]00:00:00.0000000 through 23:59:59.9999999100 nanoseconds
dateYYYY-MM-DD00001-01-01 through 9999-12-311 day
smalldatetimeYYYY-MM-DD hh:mm:ss1900-01-01 through 2079-06-061 minute
datetime YYYY-MM-DD hh:mm:ss[.nnn]1753-01-01 through 9999-12-310.333 second
datetime2YYYY-MM-DD hh:mm:ss[.nnnnnnn] 0001-01-01 00:00:00.0000000 through 9999-12-31 23:59:59.9999999100 nanoseconds
datetimeoffsetYYYY-MM-DD hh:mm:ss[.nnnnnnn] [+-]hh:mm00001-01-01 00:00:00.0000000 through 9999-12-31 23:59:59.9999999 (in UTC)100 nanoseconds


Source: http://blogs.msdn.com/usisvde/archive/2007/11/05/get-a-date.aspx

Friday, November 02, 2007

WCF Tutorial

My first attempt at using WCF, thanks to http://msdn2.microsoft.com/en-us/vbasic/bb736015.aspx was very successful.

I did change the language to C# for my version, since I perfer it over VB.Net. There were some changes that I had to go about in a different way to get it to be successful.

Example:

Dim t As Type = GetType(ServiceLib.HelloService)

vs.

ServiceLib.HelloService hs = new ServiceLib.HelloService();


Type t = Type.GetTypeArray(new object[]{hs})[0];