Monthly Archives: February 2015

xampp redirects localhost to website

Make sure the first entry in conf/extra/httpd-hosts.conf is this

Error: Apache shutdown unexpectedly xampp

16:50:25 [Apache] Status change detected: running
16:50:26 [Apache] Status change detected: stopped
16:50:26 [Apache] Error: Apache shutdown unexpectedly.
16:50:26 [Apache] This may be due to a blocked port, missing dependencies,
16:50:26 [Apache] improper privileges, a crash, or a shutdown by another method.
16:50:26 [Apache] Press the Logs button to view error logs and check
16:50:26 [Apache] the Windows Event Viewer for more clues
16:50:26 [Apache] If you need more help, copy and post this
16:50:26 [Apache] entire log window on the forums

How to resolve?

First check this StackOverflow question.

Make sure it is not Skype Issue. Make sure another application is not creating conflict with Apache on port 80. Make sure it is not a firewall issue. click “NetState” button on the right. Make sure port 80 is not used by any program. If that is all set the proceed below.

It is likely Virtual Host Issue

In the new version of xampp, if there is an error or misconfiguration in virtual host, Apache server will not start. Take default example of virtual host, for example.

These errors can be of various form for example

  • Document root is incorrect path
  • Error log is incorrect path
  • Document root is not point to correct folder (/ at end of folder name)

To make sure it is not a vitual host issue, uncomment virtual host in xampp/apache/conf/http.config (line 501)

Hopefully this will resolve the problem. If either case, move to next step.

Fix Your Virtual Host Setting

As I pointed about any small misconfiguration in virtual host will cause apache not to start. So the best way to look at is to start apache from shell (command prompt).

In XAMPP Control Panel V3.2.1, click on “Shell” icon. This will take you to a screen like this

2015-02-28 22_00_26-Administrator_  XAMPP for Windows

Type “ap” then TAB 2 times

This will start Apache. The benefit of starting Apache from command prompt is, you will actually see errors in case it fails. It might throw some usefull error like line no 2 in Virtual host in correct path for example. Just fix that and restart and hopefully that will fix the problem.

SQL Cascaded JOIN

This is a form of JOIN that I was not aware of too after working with SQL for so many years. It’s syntax is as below:

That is it uses JOIN keyword wihtout using ON keyword and then it used two ON keywords one after another.

analyse sql query

The following regex can be used to get the table name from an sql query

or better

Group 1 (^from) is used to get location of table.
Group 2 (([a=zA-Z0-9_]*) is used to get table name
[space]* is used to match white spaces between from and table name.

favicon not showing

You have updated your favicon but it is not showing. Even worse you are seeing the old default favicon after refreshing the page so many times. You even cleared the cache but even then it is the old favicon that is showing. To add up to agony, on some computers you are seeing new favicon but on other it is still the old icon that is showing.

This is most likely caching issue. Looks like the favicon wont go way by simply clearing the cache. There are other techniques to to clear all bookmarks and then it would go away. I will give a simple tip that will at least fix the problem for the time being without clearing your bookmarks.

Fix (Temporary)

  1. Go to your site, in this case lets try Notice that old favicon is showing.
  2. Go to, notice that still  your old icon is showing.
  3. Now refresh your page by click refresh icon in the address bar of your browser. Try this a couple of times unless it works. If it does not work, try other techniques to refresh the page so the new icon is loaded. Hurray now your new icon appears.
  4. Now in the *same* window browse to your site. It should show the new favicon.

If you open a new window  or TAB it might still show the old favicon but at least you got it work to what it should look like.

invoke delegate with parameters

Download Ping Example Code (10kb)

The following is a simple code to invoke a delegate with parameter. I created this to update label control on the form asynchronously. I did not quite work I was hoping for but the code does pass parameter to the delegate

AP.NET misplaced tags can give you big headache

ill formed tag
I was trying to add a new tab to the existing 2 tabs. I copied some 250 lines of code of the second tab, changed all IDS and ControlIDs for validation etc and finally made the code work. But only to find out that my tab3 would not appear, even though its heading did. I spend some time over this and tried to figure out what I am missing. After all I did not work with ASP.NET TABS before.

Eventually found out that the contents of TAB3 were not showing because they were embedded one level below. I tried to find out what could be the cause but the panel itself seemed fine and were placed adjacent to each other. Then I set out on validating every control inside the TAB, from top to the bottom, starting with panel, tables and gridviews. Found out one anomaly where the code was like this

See that </tr> and </table> are interrupted by </panel>. It should have been like this

It took me 2 days to find out this was the cause of the problem. Now my TAB3 is working fine and I can work on real code rather than why TAB3 is not working :)

How to add program to Windows Service?

If you want to add your own program to Windows Service (as you might want to keep track of things), there is an excellent utility that you can use. It is called NSSM Non-Sucking Service Manager. Download it from the above link (use correct version 32vit or 64) then unzip it and lets save it to c:\services folder or anywhere else you prefer.

Use the following command to add a program to services

This will popup a gui. Click the browse button to navigate the program that you want to start as service. Note that you can put Applications that has GUI into startup but the GUI part will not work (it will not be displayed) but the code behind will work.

How to Uninstall a Windows Service

Issue this command

It will ask to confirm remove of the windows service. Click ok and it will be remove from services.

Please not that both the above commands can be start with out supplying *ServiceName*. In that you will be asked to type service name in the graphical user interface.

Here is complete help about nssm

Add a linked Server in SSMS

Add linked Server in SSMSI was having issue with running a linked server query and getting the following error

Msg 11529, Level 16, State 1, Procedure sp_describe_first_result_set, Line 1
The metadata could not be determined because every code path results in an error; see previous errors for some of these.

I played with various functions to fixed the problem, namely sp_serveroption, sp_addlinkedsrvlogin but nothing fixed the error. Eventually I found that we can Linked Server in SQL Server Management Studio using a GUI. I tried that and it fixed the error for me. This is how to add linked server in SSMS

1. In SQL Server Management Studio go to “Server Object” on the root level on left hand side in “Objects Explorer”.
2. Expand “Linked Server” + sign to any linked server if any.
3. Right click on Linked Server and select “Add New Linked Server”
4. Select SQL Server Radio box
5. In the Security option below general, select “Be made using this security context”. Provide your remote db login name and password. Usually login name will be “sa”.
6. Select OK

Now run query against your server using the following sample code

You can try adding linked server from command line as well. Make sure to delete you linked Server by right clicking on it and delete so no one can use it!