Follow me on Twitter Two weeks ago I decided to prep my development VMWare Workstation in anticipation of the yet-to-be-announced SharePoint 2010 beta 2 release. After some futile attempts at installing W2K8 server, I realized that it was time to upgrade my VM software from version 6 to 7. After forking out the $99 (well worth it IMHO), I encountered the first hurdle when attempting to create the VM: my machine was not "VT enabled"... Apparently my host machine, which is a HP dt5000 desktop with 8GB of RAM and two quad cores wasn't up to the task :-O VT stands for Virtualization Technology and it's basically the processor equivalent of a V8 Dodge Challenger.

Some machines are VT-capable but are not VT-enabled when shipped. It's pretty common for laptops not to have this enabled. I called HP Support and ended up re-booting my machine and updating the BIOS to enable VT-Threading. Not so long ago, PC support technicians would respond to such a request with "do it but keep a fire extinguisher handy"...

Here are my machine specs...

Intel Core2 Quad CPU Q9450 2.66GHz 4 cores
Bios: American Megatrends 5.16 6/19/2008
Vista Ultimate 6.0.6002 SP2 Build 6002

 

...and the steps to perform this task - steps should be similar irrespective of the machine:

1. Turn off the PC and then again turn on the PC
2. After you get the HP logo screen immediately keep tapping the f10 key after the HP logo screen to enter in to BIOS set up screen
3. In the BIOS set up screen select the “Power” tab
4. Under the Power tab you will find the option “Virtualization Technology”
5. You need to enable it and then press f10 key on the keyboard to save and exit
6. Re-start machine

 

From the moment PDC09 began, the blogosphere has been alight with posts about installing this beta, so I'm not going to give overly-detailed instructions. Instead, I want to focus in on the gotchas that can make this an unpleasant experience for non-admin devs like myself. I'm also providing the links you need at the end of this post.

Developer in Admin Role As I write, I have just (successfully) re-created the install of SharePoint on my VM for the third time, in an efort to get this right. Previous attempts resulted in various errors, which though unforseen, were still my fault. One tip: I use VirtualCloneDrive to mount my ISO (DVD) images when creating VMs and it works on 64-bit. I also use ClamWin Anti-Virus for 64-bit. Create a strong password for your (admin) account with a mix of at least capital and small letter and numbers - you'll see why in a bit.

After the OS is installed, if you start getting license activation errors in the log, go to Start -> Control Panel and click on the "Change Product Key" link. When prompted, enter your valid licensed product key and the product activation will complete successfully.

You may also want to install the KB 971831 hotfix which "provides a method to support the token authentication without transport security or message encryption in WCF is available for the .NET Framework 3.5 SP1."

Now it's time to install SQL Server 2008 - 2005 will work also but involves different patches:

Script to open SQL Server ports:
http://support.microsoft.com/default.aspx/kb/968872

SQL Server 2008 SP1:
http://bit.ly/9QGGhX

CU2 for SP1:
http://support.microsoft.com/kb/970315

Add your admin account in SSMS and grant permissions for the following roles:

* securityadmin fixed server role
* dbcreator fixed server role

Important: If you plan to run Windows PowerShell cmdlets that affect a database, this account must be a member of the db_owner fixed database role for the database.

Next, grab Powershell 2.0 and install it. The SharePoint Pre-Requisites checker failed on this for me several times because of the older version of Powershell being present.

Install Menu

 

Next install SharePoint 2010. When the SharePoint Server 2010 menu appears, first click on the "Install software prerequisites" link. After this successfully completes, click on the link to actually install SharePoint Server. Choose Server Farm and Complete from the wizard menu options. This is the part that catches most people. The terminology here leaves a lot to be desired and I'm surprised that it's still being used in this version - <rant>they let the marketing assholes rename almost everything else so why stop there?</rant>

Important: Do not run the Products and Technologies Configuration Wizard after the wizard completes.

Install Type

 

With the 2010 version we cannot automatically run everything with a local account. This is retarded because in most cases people do not want to set up AD and DC for a simple dev VM. Luckily, there is a workaround with Powershell - just follow the simple steps and use the strong password we created earlier, when prompted.

Now we can run the Products Configuration Wizard from the Start menu and use our local account when prompted for such info by the wizard. On completion, you will be presented with the Farm Configuration Wizard - take the dummies option (default) and you will be led by the reins to the complete setup of your site collection and top level home site. This is a huge improvement over the 2007 version. What's even better is that with the introduction of the new Service Application Architecture we no longer have to go through the process of creating the now deprecated Shared Services Provider (SSP).

Home Page
 

 

Next task will be to install VS 2010 Ultimate and SharePoint Designer 2007...

UPDATE - 12-12-2009:

I have since been re-building my machine and I would like to point out something that I missed the first time around: before manually installing Powershell 2.0, you have to uninstall the 1.0 version that comes with the OS. You can do this by clicking on the 'Remove Feature' link in Server Manager.

kick it on DotNetKicks.com




I recently had a DropDownList being pre-populated from a database. I also wanted to insert "Select" at the top of the list and make it a required field. Googling this yielded much misinformation for what turned out to be pretty simple to solve in the end.

Say you have a DDL like this:

<asp:DropDownList id="testDDL" runat="server">
    <asp:ListItem Text="Select"></asp:ListItem>
</asp:DropDownList>

 

If we try to populate this DropDownList from a database with the values 1,2 and 3, and then try and add a RequiredFieldValidator, that validator will not fire.

Some people resort to creating a CustomValidator and/or JavaScript here. This is not necessary. We need to take a step back here and re-phrase the problem: We already have data in our list in the shape of the "Select" item. We now want to append data from the database. A quick search of the MSDN documentation leads to the AppendDataBoundItems property for the DropDownList.

From the documentation: "The AppendDataBoundItems property allows you to add items to the ListControl object before data binding occurs. After data binding, the items collection contains both the items from the data source and the previously added items." The italics are mine...

We can use the InitialValue of the RequiredFieldValidator in conjunction with the AppendDataBoundItems property of the DropDownList to arrive at a working solution:

<asp:DropDownList id="testDDL" AppendDataBoundItems="true" runat="server">
    <asp:ListItem Text="Select"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="salaryReqVal" ControlToValidate="salaryDDL"
    ErrorMessage="*" Display="dynamic" InitialValue="Select"
        runat="server"></asp:RequiredFieldValidator>




Incorrect Format

 

Here's the scenario: I'm building a basic 3-layer Web application for a client with business and data layers. Queries are performed in stored procedures, just basic ADO.NET. The table I am attempting to insert a record into has a range a field types such as strings, ints, decimals, etc.

If the user is entering integer or decimal values via texboxes, which is usually the case, then you have to expect either no data or a string of possibly mal-formed data. You must filter out the mal-formed data with validation and/or convert the resulting input data to the expected database type.

If you have a database field called SquareFeet of type int and you attempt to insert the following in your code-behind insert method, you will probably see this error:

// Results in error message
AddSomething(int squareFeet)
{
    Convert.ToInt32(SquareFeetTxtBox.Text.Trim());   
}

 

You must be careful if you are trying to fetch, say, an int or decimal as input:

// Correct way if SquareFeet field is an int
int squareFeet
if (int.TryParse(squareFeetTxt.Text.Trim(), out squareFeet))
    squareFeet = Convert.ToInt32(squareFeetTxt.Text.Trim());
else
     squareFeet = 0;
// Now insert the value as part of the record

 

// Correct way if SquareFeet field is a decimal
int squareFeet
if (decimal.TryParse(squareFeetTxt.Text.Trim(), out squareFeet))
    squareFeet = Convert.ToDecimal(squareFeetTxt.Text.Trim());
else
     squareFeet = 0.0m;
// Now insert the value as part of the record

 

References

Refer to these links for the differences between Convert.ToInt, int.Parse and Int.TryParse:
http://dotnetperls.com/int-parse-conversion
http://dotnetperls.com/int-tryparse

Refer to this link for an explanation of the 0.0m decimal syntax:
http://msdn.microsoft.com/en-us/library/364x0z75(VS.80).aspx

Moral of the Story
If you are learning any language, your first priority must be to understand the types thoroughly. Resist the temptation to gloss over the grammar just to get to the fancy stuff! :-)

kick it on DotNetKicks.com

Tags: , ,

ASP.NET | C#