Friday, December 11, 2009
Wednesday, November 18, 2009
Silverlight 4 Beta - developer release
http://silverlight.net/getstarted/silverlight-4-beta/
"This latest version delivers hundreds of features and controls that, when combined with the continued innovation in Microsoft’s world-class tools for designers and developers — Microsoft Visual Studio and Microsoft Expression Blend – present the leading edge in rapid, powerful application development. With printing support, rich reporting and charting, and integration with back-end systems and server products including Microsoft SharePoint, Silverlight is ready for business."
"IMPORTANT DEVELOPER NOTE:
Visual Studio 2010 can be installed side-by-side with Visual Studio 2008 SP1. For Silverlight 4 development, you will need Visual Studio 2010. Please read the known issue on installing Visual Studio 2010 if you already have the Silverlight 3 SDK installed."
Videos and Samples
http://silverlight.net/learn/videos/silverlight-4-beta-videos/

"This latest version delivers hundreds of features and controls that, when combined with the continued innovation in Microsoft’s world-class tools for designers and developers — Microsoft Visual Studio and Microsoft Expression Blend – present the leading edge in rapid, powerful application development. With printing support, rich reporting and charting, and integration with back-end systems and server products including Microsoft SharePoint, Silverlight is ready for business."
"IMPORTANT DEVELOPER NOTE:
Visual Studio 2010 can be installed side-by-side with Visual Studio 2008 SP1. For Silverlight 4 development, you will need Visual Studio 2010. Please read the known issue on installing Visual Studio 2010 if you already have the Silverlight 3 SDK installed."
Videos and Samples
http://silverlight.net/learn/videos/silverlight-4-beta-videos/
Silverlight 4 Beta - developer release
Sunday, November 8, 2009
T-SQL - NULL does not equal NULL
Be careful of this when coding. NULL does not equal NULL, you can test it with following code, weird? No! because NULL does not present a value to be able to be equal to another value!
IF (NULL=NULL)
PRINT 'NULL is equal to NULL'
ELSE
PRINT 'NULL is not equal to NULL !'

IF (NULL=NULL)
PRINT 'NULL is equal to NULL'
ELSE
PRINT 'NULL is not equal to NULL !'
T-SQL - NULL does not equal NULL
Saturday, November 7, 2009
T-SQL - Aggregate functions and NULL values in numeric fields
Except COUNT(*), all other aggregate functions ignore NULLs. As an example if you have NULL value in a numeric field, the NULL value does not equal to zero. Look at the following code, it shows the AVG function ignores the records which their specific column has NULL value.
CREATE TABLE theTable
(
theId int IDENTITY NOT NULL,
theValue DECIMAL(10,2) NULL
)
INSERT INTO theTable
(theValue)
VALUES
(NULL), (0), (1), (2), (3), (NULL)
SELECT AVG(theValue) as AverageValue
FROM theTable
The result is 1.500000
It's important when you want to design your database and tables, because it will affect the queries result when you run them against the database.
On the other hand, it's possible to consider COALESCE function (http://msdn.microsoft.com/en-us/library/ms190349.aspx), it gives you a chance to select first non NULL expression among its arguments. Then you can send multiple field names and let the COALESCE find the first non NULL value for your aggregate function, it can be happen if you have alternative field but it's tricky and depends on business rules in your application.

CREATE TABLE theTable
(
theId int IDENTITY NOT NULL,
theValue DECIMAL(10,2) NULL
)
INSERT INTO theTable
(theValue)
VALUES
(NULL), (0), (1), (2), (3), (NULL)
SELECT AVG(theValue) as AverageValue
FROM theTable
The result is 1.500000
It's important when you want to design your database and tables, because it will affect the queries result when you run them against the database.
On the other hand, it's possible to consider COALESCE function (http://msdn.microsoft.com/en-us/library/ms190349.aspx), it gives you a chance to select first non NULL expression among its arguments. Then you can send multiple field names and let the COALESCE find the first non NULL value for your aggregate function, it can be happen if you have alternative field but it's tricky and depends on business rules in your application.
T-SQL - Aggregate functions and NULL values in numeric fields
Monday, October 26, 2009
ASP.NET - CSS ID selector vs. CSS class for custom server controls
To have a common use control, we do create custom ASP.NET server controls.
As a simple example let's have a side bar control. To do that, Add a Web User Control, it has .ascx extention and call it sideBarList.
<%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="sideBarList.ascx.cs"
Inherits="AspAdvWrk01.sideBarList" %>
<asp:Panel ID="srchEnginePnl" runat="server">
<h4>Search Engines:</h4>
<a href="http://www.bing.com/">bing</a><br />
<a href="http://www.google.ca/">Google</a><br />
<a href="http://m.www.yahoo.com/">Yahoo</a><br />
<a href="http://www.msn.com/">MSN</a><br />
<a href="http://www.altavista.com/">Altavista</a>
</asp:Panel>
Then let's add the following CSS codes in a style sheet:
#srchEnginePnl
{
border-style:dotted;
border-width:1px;
padding: 5px;
font-size:small;
}
I tried the same ID name of asp Panel control in this style sheet as a CSS ID selector, To apply style to the asp Panel control with ID name of srchEnginePnl. Even though that we have CSS ID selector but it doesn't apply any style because the real ID name in HTML page is something else which you can find it by checking the html source of the page in your browser (in the test page it was #ctl00_ContentPlaceHolder1_sideBarList1_srchEnginePnl).
The solution, a CSS class selector and utilizing CssClass attribute as following:
.srchEnginePnl
{
border-style:dotted;
border-width:1px;
padding: 5px;
font-size:small;
}
a.srchEnginePnl
{
padding: 10px;
}
...
<asp:Panel ID="srchEnginePnl" CssClass="srchEnginePnl" runat="server">
...
otherwise you have to use the real ID of your panel control in html source and use that ID name to define the ID CSS selector in your style sheet:
#ctl00_ContentPlaceHolder1_sideBarList1_srchEnginePnl
{
border-style:dotted;
border-width:1px;
padding: 5px;
font-size:small;
}
...
<asp:Panel ID="srchEnginePnl" runat="server">
...

As a simple example let's have a side bar control. To do that, Add a Web User Control, it has .ascx extention and call it sideBarList.
<%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="sideBarList.ascx.cs"
Inherits="AspAdvWrk01.sideBarList" %>
<asp:Panel ID="srchEnginePnl" runat="server">
<h4>Search Engines:</h4>
<a href="http://www.bing.com/">bing</a><br />
<a href="http://www.google.ca/">Google</a><br />
<a href="http://m.www.yahoo.com/">Yahoo</a><br />
<a href="http://www.msn.com/">MSN</a><br />
<a href="http://www.altavista.com/">Altavista</a>
</asp:Panel>
Then let's add the following CSS codes in a style sheet:
#srchEnginePnl
{
border-style:dotted;
border-width:1px;
padding: 5px;
font-size:small;
}
I tried the same ID name of asp Panel control in this style sheet as a CSS ID selector, To apply style to the asp Panel control with ID name of srchEnginePnl. Even though that we have CSS ID selector but it doesn't apply any style because the real ID name in HTML page is something else which you can find it by checking the html source of the page in your browser (in the test page it was #ctl00_ContentPlaceHolder1_sideBarList1_srchEnginePnl).
The solution, a CSS class selector and utilizing CssClass attribute as following:
.srchEnginePnl
{
border-style:dotted;
border-width:1px;
padding: 5px;
font-size:small;
}
a.srchEnginePnl
{
padding: 10px;
}
...
<asp:Panel ID="srchEnginePnl" CssClass="srchEnginePnl" runat="server">
...
otherwise you have to use the real ID of your panel control in html source and use that ID name to define the ID CSS selector in your style sheet:
#ctl00_ContentPlaceHolder1_sideBarList1_srchEnginePnl
{
border-style:dotted;
border-width:1px;
padding: 5px;
font-size:small;
}
...
<asp:Panel ID="srchEnginePnl" runat="server">
...
ASP.NET - CSS ID selector vs. CSS class for custom server controls
Sunday, October 25, 2009
Visual Studio 2010 and .NET Framework 4 Training Course

Links to new Interview videos and How Do I clips and new posts about Visual Studio 2010 Beta2 in Channel 9.
http://channel9.msdn.com/learn/courses/VS2010/
"The Visual Studio 2010 and .NET Framework 4 Training Course includes videos and hands-on-labs designed to help you learn how to utilize the Visual Studio 2010 features and a variety of framework technologies including:
- C# 4.0
- Visual Basic 10
- F#
- Parallel Computing Platform
- WCF
- WF
- WPF
- ASP.NET AJAX 4.0
- ASP.NET MVC Dynamic Data."
Visual Studio 2010 and .NET Framework 4 Training Course
Tuesday, October 20, 2009
Visual Studio 2010 and .NET Framework 4 Beta 2

The Visual Studio 2010 and .NET Framework Beta 2 is available to MSDN subscribers on Monday, October 19th. Visual Studio 2010 Beta 2 and Dot Net framework 4 Beta 2 will be made available to the general public on 21st October. Users will be able to get their hands on the final version of Visual Studio 2010 on 22nd March 2010.
http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx
Visual Studio 2010 and .NET Framework 4 Beta 2 Walkthroughs
http://msdn.microsoft.com/en-us/vstudio/dd441784.aspx
Testers to get Visual Studio 2010 Beta 2 this week; final by March 2010
http://blogs.zdnet.com/microsoft/?p=4270&tag=content;col1
Other links:
Microsoft names Visual Studio 2010 dates
http://www.theregister.co.uk/2009/10/19/visual_studio_2010_second_beta_packaging/
http://msdn.microsoft.com/en-us/vstudio/default.aspx
http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx
Visual Studio 2010 and .NET Framework 4 Beta 2
Sunday, October 11, 2009
Visual Studio - An error occurred loading this property page
If you found out that the "Design, Split, Source" buttons are not available anymore, your first reaction would be to take a look at Tools->Options->HTML Designer, at this point probably you encounter with this error message:
"An error occurred loading this property page"
I encountered with the error and it was resolved by running "devenv /setup" in Visual Studio 2008 Command Prompt and restarting Visual Studio. The "Design, Split, Source" buttons came back to the right place after running that command.

"An error occurred loading this property page"
I encountered with the error and it was resolved by running "devenv /setup" in Visual Studio 2008 Command Prompt and restarting Visual Studio. The "Design, Split, Source" buttons came back to the right place after running that command.
Visual Studio - An error occurred loading this property page
Saturday, October 10, 2009
ASP.NET - Image handler to fetch and show Images from varbinary(MAX)
Imagine you want to get images from [Production].[ProductProductPhoto] table in AdventureWorks SQL sample database. The following code can be in a generic handler (.ashx) file.
public class ImgHandler : IHttpHandler
{
private string sqlCnStr =
ConfigurationManager.ConnectionStrings["CnStrAdvWrk"].ConnectionString;
public void ProcessRequest(HttpContext context)
{
string productId = context.Request.QueryString["PrdId"];
if (string.IsNullOrEmpty(productId))
productId = "1";
using (SqlConnection sqlCn = new SqlConnection(sqlCnStr))
{
StringBuilder cmd = new StringBuilder();
cmd.Append("SELECT PrdPhoto.[ThumbNailPhoto] as PrdPhoto ");
cmd.Append(" FROM [Production].[Product] as Prd ");
cmd.Append(" JOIN [Production].[ProductProductPhoto] as PPrdPhoto ");
cmd.Append(" ON Prd.ProductID = PrdPrdPhoto.ProductID ");
cmd.Append(" JOIN [Production].[ProductPhoto] as PPhoto ");
cmd.Append(" ON PPrdPhoto.ProductPhotoID = PPhoto.ProductPhotoID ");
cmd.Append(" WHERE Prd.[ProductID] = " + productId);
sqlCn.Open();
SqlCommand sqlCmd = new SqlCommand(cmd.ToString(), sqlCn);
SqlDataReader sqlDtaRdr = sqlCmd.ExecuteReader();
sqlDtaRdr.Read();
context.Response.BinaryWrite( (byte[]) sqlDtaRdr[0] );
sqlCn.Close();
context.Response.End();
}
}
public bool IsReusable
{
get { return false; }
}
}
Now you just need to call the handler.
If you have an image control and you know the ProductId:
<asp:Image ID="Image1" runat="server"
ImageUrl="~/ImgHandler.ashx?PrdId=1" />
or if you have a GridView and you want to have a column with product images, then you can use TemplateField with and Image control inside the ItemTemplate:
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:Image ID="Image1" runat="server"
ImageUrl='<%# "ImgHandler.ashx?PrdId=" + Eval("PrdId") %>' />'
</ItemTemplate>
</asp:TemplateField>

public class ImgHandler : IHttpHandler
{
private string sqlCnStr =
ConfigurationManager.ConnectionStrings["CnStrAdvWrk"].ConnectionString;
public void ProcessRequest(HttpContext context)
{
string productId = context.Request.QueryString["PrdId"];
if (string.IsNullOrEmpty(productId))
productId = "1";
using (SqlConnection sqlCn = new SqlConnection(sqlCnStr))
{
StringBuilder cmd = new StringBuilder();
cmd.Append("SELECT PrdPhoto.[ThumbNailPhoto] as PrdPhoto ");
cmd.Append(" FROM [Production].[Product] as Prd ");
cmd.Append(" JOIN [Production].[ProductProductPhoto] as PPrdPhoto ");
cmd.Append(" ON Prd.ProductID = PrdPrdPhoto.ProductID ");
cmd.Append(" JOIN [Production].[ProductPhoto] as PPhoto ");
cmd.Append(" ON PPrdPhoto.ProductPhotoID = PPhoto.ProductPhotoID ");
cmd.Append(" WHERE Prd.[ProductID] = " + productId);
sqlCn.Open();
SqlCommand sqlCmd = new SqlCommand(cmd.ToString(), sqlCn);
SqlDataReader sqlDtaRdr = sqlCmd.ExecuteReader();
sqlDtaRdr.Read();
context.Response.BinaryWrite( (byte[]) sqlDtaRdr[0] );
sqlCn.Close();
context.Response.End();
}
}
public bool IsReusable
{
get { return false; }
}
}
Now you just need to call the handler.
If you have an image control and you know the ProductId:
<asp:Image ID="Image1" runat="server"
ImageUrl="~/ImgHandler.ashx?PrdId=1" />
or if you have a GridView and you want to have a column with product images, then you can use TemplateField with and Image control inside the ItemTemplate:
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:Image ID="Image1" runat="server"
ImageUrl='<%# "ImgHandler.ashx?PrdId=" + Eval("PrdId") %>' />'
</ItemTemplate>
</asp:TemplateField>
ASP.NET - Image handler to fetch and show Images from varbinary(MAX)
Wednesday, October 7, 2009
Error 2738 - during installation of Adventure Works sample databases on Vista
Well, I downloaded Adventure Works sample databases from the here
but I encountered with error 2738 during installation.
I found the solution by a post in Mitch Denny blog:
http://notgartner.wordpress.com/2008/07/12/the-error-code-is-2738/
In brief the solution was to register VBSCRIPT.DLL on Vista which is not registered by default.
- Run "Command Prompt" as administrator
- Switch to "C:\WINDOWS\SysWOW64"
- Execute "REGSVR32.EXE VBSCRIPT.DLL"

but I encountered with error 2738 during installation.
I found the solution by a post in Mitch Denny blog:
http://notgartner.wordpress.com/2008/07/12/the-error-code-is-2738/
In brief the solution was to register VBSCRIPT.DLL on Vista which is not registered by default.
- Run "Command Prompt" as administrator
- Switch to "C:\WINDOWS\SysWOW64"
- Execute "REGSVR32.EXE VBSCRIPT.DLL"
Error 2738 - during installation of Adventure Works sample databases on Vista
Subscribe to:
Posts (Atom)
