.NET C#.NET Operating System Programming

Read System TimeZone to DB

I was looking for the TimeZone Database which also need to told me if Given Timezone is DayLightSaving enabled or not. After searching few hours on Internet I found few database that do not tell the Daylight Saving stuff. Then I found a function in TimeZoneInfo class that list all System Timezone, I loop through it and got what I need.

using (SqlCommand sqlCmd = new SqlCommand(“”, Connection.MyConnection))
sqlCmd.CommandText = “Insert into tblTimezone (TimeZone, TimeZoneDifference, isDST) Values(@TimeZone, @TimeZoneDifference, @isDST)”;
sqlCmd.Connection = Connection.MyConnection;
foreach (TimeZoneInfo tzi in TimeZoneInfo.GetSystemTimeZones())
sqlCmd.Parameters.AddWithValue(“@TimeZone”, tzi.DisplayName);
sqlCmd.Parameters.AddWithValue(“@TimeZoneDifference”, tzi.BaseUtcOffset.ToString());
sqlCmd.Parameters.AddWithValue(“@isDST”, (tzi.SupportsDaylightSavingTime ? 1 : 0));

Keep it simple 🙂

.NET ASP.NET Blog: My thoughts C#.NET Joyous

Working Lot of new methodology

It is good to back as programmer. Loving my new phase of development career, I got involved in development of a online card game. After lot of thinking and reading, I decide to use some new technology and methodology which I have been hearing about a lot. I don’t dare to use them as I feel the kind of project we were doing lately are not big enough to learn and implement those concepts. After for this project it really become necessity to these technology rather than just a decision making. For example to build a game UI, I have three option GDI+, DirectX or WPF.. I have done GDI+ before and doesn’t feel it is best to make complex Graphical interface even for like of poker game. Though I use it to build Chess Interface, but I know how problematic it was. Second came in DirectX, the best but the complex solution. I need more time to learn it and project is getting delayed. Then I choose to learn and work on WPF which is relatively easier than DirectX.

It was really a nice decision to choose WPF. It is not only easier for me to learn as I already have some experience in HTML and web programming, but it give me control which is best suited for programmer of my culture. With no efforts I am now able to create a better looking UI. Ofcourse I didn’t test the UI on Windowx XP yet, but otherwise it looks great. I am not going to test it on Windows XP anyways as we don’t going to support it. Once I have the UI ready. I need to now communicate with Online database. So for this I already know the solution called as Web Services. But where will I found the Web Service in Visual Studio 2010 .. oh I think they rename it as WCF.. nope, they make a new concept altogether called WCF. Hmm.. with past experience of webservice I know that it was the perfect solution for me, but again WCF is almost similar no difference to code, so what harm it does to use it. Afterall it bring some new security measure and ease. So I again learn WCF and it took me 1 hr to cover the difference between Web Service and WCF and I am up and ready with my solution.

Making game UI is really so exciting that I am now looking for opportunity to upgrade my Chess game to WPF interface. Programming is really fun with those concept of programming and tools that I learn in recent past. It was complex then before in planning, but easy to implement. However the attitude of programmer is they need something ease to plan and implementation they are not bothered. I must suggest using WPF and WCF in your project where you need them. I haven’t try but they says WPF and Silverlight has same code or reusable. Well if that is the case then surely I will start giving Silverlight solution in next quarter or so.

.NET Server Configuration

.NET 4.0 On IIS 6

With my dedicated Windows 2003/IIS 6.0 server I want to run latest version of .NET framework on it. Hence I use my Web Platform Installer to install .NET 4.0. Everything goes smooth. It was piece of cake to install it.

Now the time came to run my first .NET 4.0 Framework application, I configure a New website in IIS. Select .NET framework 4.0 from ASP.NET tab in Website property. But what I found is I am getting 404 error. Strangely enough that Default.aspx page does exists and with .NET 2.0 it works just fine. So what goes wrong ? I search and experiment with web.config, but to no avail.

Then I found this article, which clearly mention that

  • Install framework 4.0 and restart [Web Platform Installer does it just fine]
  • IIS 6.0 console should now display ASP.NET 4.0 under tab “ASP.NET” [It was again done if #1 above is right]
  • Under Web Services Extensions (in IIS console) .NET 4.0 framework might be set as: prohibited. This must be ALLOWED otherwise a browser might just return the error 404 page not found which is not very descriptive
  • ASP.NET 4.0 applications must be run in a separate process (Application Pool) otherwise you’ll get the error ‘Server Application Unavailable’.

It is anyways always good to run different programming languages in different pool. For Example, if you want to run PHP on same server I use different pool for them. Covering those 4 steps I got my server working with .NET 4.0. Wondering why Web Platform Team forgot to complete 2 step in their installer.

.NET ASP.NET Blog: My thoughts PHP

Make Web Not War

This is what Microsoft has to say through it’s WEB portal ( ), where it distribute one of leading platform for Web application development and deployment.

Well this message can be a direct/indirect attack on those who thing Microsoft is up again only making $$$ and not services. Well guys you are wrong, check this website out. You will find PHP and hence any software made on PHP works fine on Windows server and that to with easy. I am using PHP on Windows from IIS 5.5 and it always work fine for me, but with IIS 7 and MS WEB it is really getting much easier to install PHP and any application on it.

I like the concept and idea, love to see same thing from Apache when they start support for .NET framework ?


OpenXML : New office file format

When I first heard that Microsoft change the file extension of MS Office Products and add “x” in them, I got surprised as that was not very common practise for me. But today when I word on that new file format, I really would say, it was a good move. Those who don’t know, Microsoft with Office 2007, has change the core of file format used by Office product, and with other office software getting popularity, they actually work on an Open File format/document format. This new file fomat is known as “office open XML” or OpenXML.

this file format is based on one idea, Create a XML of Data and formatting in file, zip it and save it. Simple and easy. This file format is not limted to MS Office, but understand it very well.

In my project I need to create an Excel file such that my user can generate a summary report in Excel fileformat on button click. All I need to do is add 10 more lines (Except data retrivel logic) in my software, include few library and I am done.

Thanks to which make my work easy, this is wrapper highlevel class based on Microsoft OpenXML Format SDK. which include some .NET assembly. This wrapper make it easy for you write Excel of Word document in few lines. A sample for ASP.NET is included from author, though I use it for Windows Application and it works like charm.


Pagination Query for SQL Server

In recent past, we got few problem when we need to do Pagination with SQL Server. I specially got frustrated when I saw that MySQL server has “limit” word that does pagination work in MySQL in best known manner for me, BUT microsoft didn’t consider that option yet. But today I found a method for SQL server that does the pagination in similar way as MySQL limit works. I am not very sure if it runs on SQL Server 2000 or earlier but it runs on SQL Server 2005. The magic word here is “ROW_NUMBER()” function that provides a Serial No. kind of Numbering to each record. So to do paging all you need to do is, make Query calling ROW_NUMBER() and you are done.

Here is sample of such query

        OVER (ORDER BY EmployeeName) AS Row,
        EmployeeId, EmployeeName, Salary
    FROM Employees) AS EMP

I took this sample and knowledge from a great resources for .NET developer. Website URL is

Hope you like the solution. Any alternative is welcome.


ZedGraph Unlocked

I was working on reporting application where I just need to create graphs and paste them on PDF file. For this I choose ZedGraph Control. It is perfect library I found. Although no new development is done on it lately. But they have nothing to code in it anyways.  They have good wiki and active forum to discuss. Anyways, previously when I use this library for same situtation i was not very sure how I use it only to create Graph file on disk. What I did was I use a Hidden Control on my Window Form application with its visibilty set to false. then I draw Graph on it and save the graph from that hidden form. Since it is a control I doesn’t know if there is any better way of doing it is available or not.

But today I thought to experiment a bit. I simply create a Class file in my application, import ZedLibrary in that class file. Create an object of ZedGraph Control within my class, Set all values that are set in my old application’s initilizecomponent function, and create disk graph as I do previously. And it works!!! i know this sound “obvious” thing to whom that know a control cannot be used without making its instance on form. But for those who are not very mature like me, they might not know this. Also, some controls are graphic bound (due to bad coding only). But seriously ZedControl is perfect in that manner.  

I learn a new thing today in .NET framework, that really tells why it is true object oriented and what we see on screen is only CODE at the end of day, so there is nothing to worries about the display if you can control it through property and methods.  

Now let me finish my project first :).