Galin Iliev's blog

Software Architecture & Development

Entity Framework for DBAs

There is a lot of noise these days around Visual Studio 2008 and fancy LINQ to SQL and Entity Framework and discussions how they will change the way data driven applications is done.

But somethign was missed 'till now - How this would affect database administrators (DBAs)?  Erick Thompson post a good explanation about these technologies that targets DBA and explain what will be changed on their daily job.

Go and read ADO.NET Blog post - it worths.

13 disasters for production web sites and their solutions by Omar Al Zabir

A great software developer and architect from Pakistan Omar Al Zabir wrote an article about disasters for production web sites and their solutions. It is very interesting as it describes how to deal with problems (and event worse - disasters) in production.

Here is the list:

  1. Hard drive crashed, burned, got corrupted several times
  2. Controller malfunctions and corrupts all disks in the same controller
  3. RAID malfunction
  4. CPU overheated and burned out
  5. Firewall went down
  6. Remote Desktop stopped working after a patch installation
  7. Remote Desktop max connection exceeded. Cannot login anymore to servers
  8. Database got corrupted while we were moving the production database from one server to another over the network
  9. One developer deleted the production database accidentally while doing routine work
  10. Support crew at hosting service formatted our running production server instead of a corrupted server that we asked to format
  11. Windows got corrupted and was not working until we reinstalled
  12. DNS goes down
  13. Internet backbone goes down in different part of the world

Here is the article 13 disasters for production web sites and their solutions

Note: You can also take a look at his website - http://omar.mvps.org/ it is very impressing with Win2k look&feel

Transactional NTFS

Can you name the common things (logical ones) between file system storage and RDBMS? For sure both stores user's and system's data. For historical reasons the engines are quite different but can they be brought closer with current level of technologies? Why not?! Microsoft has made an attempt with WinFS but this adventure threatened Windows Vista relesase and was dropped from Vista. This mean we won't see it in Windows Server 2008 either as they share same core AFIAK.

But still we can have small good even now - transactions in file system or trade name - Transactional NTFS (TxF)

There is a good article explaining TxF in July 2007 issue of MSDN Magazine.

The easiest use of TxF is with native code. Being .NET developer this isn't that good for me but in the article's sample code is placed a basic wrapper you could start with.

If you're interested but too lazy to read take a look at Channel9 screencast Developer, Meet Server #1 - Transactional NTFS

Visual Studio 2008 (When to expect?)

It is amazing how many improvements was made from VS 2003 to VS 2005. I remember the time when I was so anxious to touch new VS 2005. MS guys are working hard (and smart) to let us waiting new VS 2008 (Orcas) in same manner.

ScottGu was very responsive to users' comments on his blog entry VS 2008 Nested Master Page Support and shares

VS 2008 Beta2 should be available for free download in the next three weeks. It will support a go-live license (Posted on July 09, 2007)

Also the date of big launch is known... as  Windows Server 2008, Visual Studio 2008 and Microsoft SQL Server 2008 Joint Launch Announced. It is Feb 27, 2008 in LA.

While the launch events are scheduled to kick off on February 27, 2008, Visual Studio 2008 will be released before the end of the year.

Let's call them with real names

On TechEd07 Microsoft announced official names of next version of Visual studio and SQL Server. Both will be named according year of the release - accordingly Visual Studio 2008 and SQL Server 2008 - following marketing strategy that started with windows 95 :)

Also there is new framework that comes to help developing rich clients - Microsoft codename "Acropolis".

The Microsoft code name “Acropolis” Community Technology Preview 1 is a set of components and tools that make it easier for developers to build and manage modular, business focused, client .NET applications. Acropolis is part of the “.NET Client Futures” wave of releases, our preview of upcoming technologies for Windows client development.

Acropolis builds on the rich capabilities of Microsoft Windows and the .NET Framework, including Windows Presentation Foundation (WPF), by providing tools and pre-built components that help developers quickly assemble applications from loosely-coupled parts and services. With Acropolis you will be able to:

  • Quickly create WPF enabled user experiences for your client applications.
  • Build client applications from reusable, connectable, modules that allow you to easily create complex, business-focused applications in less time.
  • Integrate and host your modules in applications such as Microsoft Office, or quickly build stand-alone client interfaces.
  • Change the look and feel of your application quickly using built-in themes, or custom designs using XAML.
  • Add features such as workflow navigation and user-specific views with minimal coding.
  • Manage, update, and deploy your application modules quickly and easily.

(via Marto Kulov's blog)

Databases tips

I have been dealing with MS SQL Server 2005 and Microsoft SQL Server 2005 Analysis Services as well as Reporting services to display results to end users.

It was amazing how many issues are in the fields of databases. I developed projects on my dev box with snapshot of database (biggest table contains aprox 200,000 rows) and I though it was done. Unfortunately I was not able to deploy in production because of following reasons:

  • cube and dimensions processing was extremely slow - this was solved with playing with indecies
  • Memory error: The operation cannot be completed because the memory quota estimate (1678MB) exceeds the available system memory  - this was on 4xCPU and 4GB RAM on 32bit Windows 2003 std. This was solved with limiting SQL Server serive memory to 2GB and set /3GB startup switch in windows.
  • then came:  Arithmetic overflow error converting expression to data type int. This was tough also because I had to wait 2:30 hours before I get the error. then I make changes and try again... this was very, very long loop. For fully understand it check SQL Server Books and as resolution check Barnabas Kendall's blog entry.

there are  some good points in Barnabas Kendall's blog entry like:

I don’t enjoy reading documentation (lack of plot and character development),   :):)

  • Create the view with the SCHEMABINDING option.
  • Define the view to pre-aggregate the data (this is where the performance enhancement comes from). For example, I have a view that splits up the year, month, day, and hour of a click, groups by client, and also returns a total. I can also reuse this view to get totals by hour, day, month, year, or all time.
  • Don’t use COUNT, use COUNT_BIG.
  • Don’t use AVG; use SUM and COUNT_BIG. Beware of integer overflows in your final query; SUM always wants to make an INT. Why isn’t there a SUM_BIG? You can get around this by using CAST or CONVERT in your final query.
  • Make a clustered unique index on the view. This forces the database engine to persist the values to disk rather than calculating them on the fly, which is what leads to five-minute queries. I am surprised to learn that you don’t need to put all the values of the table in the index, just the ones necessary to make a clustered unique index.
  • When querying the view, use the NOEXPAND hint.


I would like to add: All aggregate functions return result depending on input parameter's type- if input column is of type int and result would be if type int:

select sum(numbers) from dbo.TestTable

And if you use SUM of multiple rows all that contains values like 2,000,000,000 you will end up with Arithmetic overflow error

In order to change result type this:

select sum(cast(numbers as bigint)) from dbo.TestTable


I employed some of these techniques and started the process again. I am keeping my fingers crossed...

Start/Stop IIS Site with C#

Have you ever had you deal with IIS management using C#? I mean IIS6?

for IIS 6 you had to deal with DirectoryEntry class like this (code got from here):


   1:  try
   2:  {
   3:      const string WebServerSchema = "IIsWebServer"; // Case Sensitive
   4:      string ServerName = "localhost";
   5:      DirectoryEntry W3SVC = new DirectoryEntry("IIS://" + ServerName + "/w3svc");
   6:      foreach (DirectoryEntry Site in W3SVC.Children)
   7:      {
   8:          if (Site.SchemaClassName == WebServerSchema)
   9:          {
  10:              Console.WriteLine(Site.Name + " - " + Site.Properties["ServerComment"].Value.ToString());
  11:          }
  12:      }
  13:  }
  14:  // Catch any errors
  15:  catch (Exception e)
  16:  {
  17:      Console.WriteLine("Error: " + e.ToString());
  18:  }


and once you find your site you had to execute DirectoryEntry.Invoke("Start", null) or DirectoryEntry.Invoke("Stop", null)  in order to start/stop the site.

Not very convinient but works :).

Well with IIS7 there are a good news and bad news... The bad news is this code won't work on IIS7 (and Vista).

The good news is that there is new .NET assembly () for managing IIS. It is located in %WinDir%\System32\InetSrv\Microsoft.Web.Administration.dll. It contains some wrapper classes that makes dev life much easier :)

with it the task above become:

   1:  ServerManager iisManager = new ServerManager();
   2:  iisManager.Sites["NewSite"].Stop(); 

Much prettier huh?! :)

for more info about Microsoft.Web.Administration.dll read CarlosAg blog's entry Microsoft.Web.Administration in IIS 7

Windows Forces you to use UAC to Add a Printer

I've been using Vista since beta 2 but I haven't had my network printer installed up to now.

Everytime I tried to install network printer I get the message saying: "Windows cannot connect to the printer. The specified print monitor is unknown." with the following screen.

I finally found solution on this here and here.

Simply said if you're in same situation then you must turn on UAC. Yes, you need UAC in order to install network printer. Once installed you can turn it off again.

Here was some intersting suggestion from javmirin:

In Vista PC's go to "Control Panel" - "Printers" - "Add printer".
Believe or not, click "Add a local printer" (I know you want to add a network printer but that way it doesn't work).
Click "Create a new port" - "Local Port" - "Next"
In the next box you have to enter a port name like this:
\\PC name\Printer name
where "PC name" is the network name of the XP PC where you have the printer and "Printer name" the network name of that printer. Be careful with this names. Check in your XP PC "Control Panel" - "Printers and faxes" - "your printer" - right click - "share" - "share resources name"
(sorry I'm translating from Spanish and not sure these are the exact terms).

 

 

Remote Desktop MMC Snap-in in Windows Vista Trick

I use Virtual PC and Remote Desktop Connection (RDC) a lot in my daily acitivities.

Recently I found that there is very nice tool built-in Windows that allows you to manage miltiple RDC.

You can start this MMC console by typing in Run command window (Win+R) tsmmc.msc.

for more detailed way to display RDC MMC Snap-in see MS TechNet's Add the Remote Desktops snap-in article.

So far so good. But I am running Windows Vista on my laptop so I need to use on it.

But guess what?! I tried it in similar way as described in Add the Remote Desktops snap-in but I was not able to add this snap-in. There is no such file as tsmmc.msc.I found this thread in TechNet forums saying there are bunch of dlls in vista that need to be registered using regsvr32 in order to be used. Unfortunately even after registering these dlls I was not able to access RDC MMC snap-in.

So I decided to try in hard way :)

After some DLL research I copied mstsmmc.dll from Windows 2003 machine to my vista box and  registered using following command:

regsvr32 mstsmmc.dll 

and Bingo. That's it. There is Remote Desktops snapp-in in the list

and of course you are able to start tsmmc.msc (also copied from Win 2003 machine)

You can download these files from the link below. Enjoy

RDC_MMC_Snap-in_Vista.zip (75.47 KB)