SQL Server 2005: Data Flow Task: The product level is insufficient for component

Problem: You fail to import data using the SQL Server Import and Export Wizard. In the validating step you check the messages only to find that it has failed because "The product level is insufficient for component..."

Solution: Rerun SQL 2005 setup on your local machine and be sure to check "Integration Services."

Note: I was confused by people telling me to look around for "SSIS" in setup. It actually goes by the name "SQL Server Intergration Services"... the windows service is conveniently names as such.

ASP.NET: Display an image from a stream

protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
Response.ContentType = "image/jpg";
System.Drawing.Image image = System.Drawing.Image.FromFile("c:\temp\somefile.jpg");
image.Save(Response.OutputStream, ImageFormat.Jpeg);
Response.End();
}
This page loads an image from disk, converts it to a stream and writes it as the response for this page. The source would probably be binary data stored in a database or from a zip file in memory.

C#: Conditional Shorthand

return (i == 1) ? true : false;
is equivalent to
if (i == 1)
return true;
else
return false;


"Null" Conditional Shorthand
return myObject ?? new Object();
is equivalent to
if (myObject == null)  
return new Object();
else
return myObject;

C#: Array initializer in a foreach loop

I find this comes in handy now and again:
foreach (string x in new string[] { "x1", "x2", "x3" }) 
{
}

SQL Server Management Studio: Enter null values

Problem: You want to enter a null value into a field using the "Open Table" view.

Solution: Press Ctrl + 0 (zero) with the field highlighted.

Notes: I kept pressing Ctrl - O (oh) and getting nowhere. I believe all fonts should use slashed zeros to prevent confusion in this matter. Works in Management Studio and Enterprise Manager.

Windows Server 2003: Turn on "allow remote desktop connections" remotely

If you get this:
The client could not connect to the remote computer.

Remote connections might not be enabled or the computer might be too busy to accept new connections.
It is also possible that network problems are preventing your connection.

Please try connecting again later. If the problem continues to occur, contact your administrator.


Try this:
  1. Connect to a machine in the domain.
  2. Start --> Run --> regedit --> OK
  3. File --> Connect Ntwork Registry
  4. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server
  5. You will find a REG_DWORD value named fDenyTSConnection. Change this from 1 to 0.
  6. Start a command prompt.
  7. Issue a restart of the machine that contains the registry change. "shutdown -m \\myserver -r"