Tuesday, January 8, 2008

Installing Windows XP in Virtual PC

When you create a new virtual machine in Virtual PC (2007 and earlier), you choose the operating system you want to install on that virtual machine so that the virtual machine settings are optimized for that operating system. Now when you choose Windows XP from the list of operating systems, you get a default value of 128 MB for the memory, don't use that default value! If you do, Windows XP will take ages to install on your virtual machine, so, change the default value to be at least 256 MB. This will make a huge difference.

Friday, January 4, 2008

Return value of ExecuteNonQuery() in the MySQL .NET Provider

As support for stored procedures was added in MySQL 5, I thought I'd blog about a difference in behavior I noticed between the SQL Server .NET Provider and the MySQL .NET Provider when executing stored procedures using ExecuteNonQuery().

You know that when you use ExecuteNonQuery() to execute a stored procedure (or any other SQL statements but we're going to talk about stored procedures here) it returns the number of records affected by the stored procedure. Now, what exactly is returned by the SQL Server Provider? I assume most developers who use the SQL Server Provider know that but in case you didn't know, the SQL Server Provider returns the total number of records affected by executing all statements in the stored procedure.

Let's take this example to make things clearer. For example, say that you have a stored procedure in which you first insert some records in a table then in the same procedure you update some records in another table. Let's assume that the procedure was executed and it inserted 5 records in the first table and updated 3 records in the second table, now what the SQL Server Provider returns exactly is the total number of records affected by executing this procedure which is 5 + 3 = 8.

On the other hand, the MySQL .NET Provider only returns the number of records affected by executing the last statement in the procedure, so referring to the preceding example, ExecuteNonQuery() will only return 3.

The point in this post is that if you're using the value returned from ExecuteNonQuery() for anything in your project, you just should be aware of the difference in behavior between the SQL Server Provider and the MySQL .NET Provider.

Happy programming!

Thursday, January 3, 2008

Sybase Annoyances

One of the things that I really hated about Sybase is its lack of support for the use of the top keyword in subquries, for example:

    (SELECT TOP 1 field1 FROM table2 WHERE id = table1.id) myfield

This works in SQL Server but not in Sybase.

This is as of Sybase ASE 12.5, I don't know if this changed in Sybase ASE 15, so, if you have any idea about it please share this with us in the comments section.

How to Open The Current Page in a New Tab in FireFox

In FireFox when you click Ctrl + T, a new tab is opened showing a blank page. But what if you want to open a new tab that shows the current page, it's simple but you'll have to do it in two steps:
1. Press Alt + D (notice that the current page address will be highlighted in the address bar)
2. Now, Press Alt + Enter (a new tab will be opened showing the current page)