Tuesday, January 30, 2007

SQL Nightmare

I maintain a web site that allows user to self register. I got a call from one user complaining that she got an error message: "User already exists." But, she is pretty sure there is no such user in our system.

So, I open up SQL Management Studio, try to query the user table. She is right, there is no duplicated user name. I look at the stored procedure, it is very clear that it found a duplicated user name and spit out this error message. What is going on?

It took me at least 20 minutes to suddenly realize that the stored procedure is wrapped in a big transaction. It is possible, a user with the same name is inserted during the transaction, before the complaining code. But, the insertion is canceled when the transaction is rolled back due to the error. I checked the stored procedure again, and did find something like this:


BEGIN TRAN
insert user A
...
... do lot of other things
...
if not exists user A
insert user A
COMMIT TRAN
else
@error="User already exists."
ROLLBACK TRAN
end


Lesson learned: transactional database can be a strange beast. What you see may not be what you think it is. Be aware!

Monday, January 29, 2007

Windows Media Player Automatically Show Full-Screen on Second Monitor

I have dual monitor setup on my laptop. If I open Windows Media Player on one monitor, it will automatically show videos on the other monitor full screen, always on top. I have no option to turn that off. This is annoying because I typically do not want to watch video full-screen. Sometimes, the little ad movie embedded on web pages will suddenly pop-out to my monitor full-screen, and I cannot close it in any way except closing the web page. To make things even worse, one of my monitor is setup to rotate 90 degrees (so that I can see more lines of code on one screen). The full-screen video will show-up on that screen in its original orientation (i.e. I have rotate my monitor back to watch it).

So, I want to turn off the feature, but cannot find anything in Windows Media options. After some googling, I found out this was a problem ever since people starting to use dual monitor configurations. I finally found a solution by adjusting my video card's settings.
http://groups.google.com/group/microsoft.public.windowsmedia.player/browse_frm/thread/2c41fd0cfe87b281/1aa491098343db1e?lnk=st&q=windows+media+player+dual+monitor+full+screen&rnum=9#1aa491098343db1e

Below is screenshot of the settings on my computer:

Wednesday, January 24, 2007

Bookmarklet (aka Favelet)

Only recently did I notice how powerful a bookmark could be. For a nice demo of what you could accomplish, follow this link: http://slayeroffice.com/tools/modi/v2.0/modi_help.html. This is definitely NOT what you would expect from adding a link to bookmark. Huge javascript code can be executed on the page you are currently browsing, by clicking on the bookmark.

There should be some security concerns here. To Microsoft's credit, IE7 did show me a warning dialog when I tried to add the bookmark. Although the warning message is rather vague about what is wrong. There is no warning when I add it to Firefox.

Tuesday, January 23, 2007

ASP.NET AJAX 1.0 released

From Atlas to ASP.NET AJAX, this nice development tool is finally released, and it is free. For ASP.NET developers, this is the time to seriously check it out. It is a huge enhancement to ASP.NET in Visual Studio 2005.

The official web site for this product: http://ajax.asp.net/default.aspx

Also check this blog for more behind scene information: http://weblogs.asp.net/scottgu/archive/2007/01/23/asp-net-ajax-1-0-released.aspx
(Scott is a Microsoft employee. His blog is one of the few I subscribe to. It has latest news about ASP.NET, IIS, and lots of tutorials.)