One of the reasons why I’m impressed with asp.net’s rich set of controls is its GridView control. This control displays your data in a table structure complete with delete, update and select features. It even has paging in case you have lots of records in your database. The best thing about this paging is that everything is done for you, the links, the paging number, the paging labels and others. If you click a page link, it will retrieve the next set of record(s) for you without changing any SQL query. For example, you can use this SQL query to retrieve all records of the table.
In MySQL, you would need to supply the LIMIT keyword in order to get a specific set of rows. With GridView’s paging feature enabled, everything is done for you. Neat huh. Took me like a day in getting this one to work though because I had problems with the update and delete function. Since I am using MySQL, turns out when you do parameters in your query commands, the @ sign does not work because it is only for MS SQL. You would have to change the @ to ?.
Take this sample asp.net code for a GridView control as an example. This assumes you have a working database connection to MySQL. If you do not know how to connect to a MySQL in asp.net, go here to use the custom MySQLProvider classes by Rakotomalala Andriniaina.
SelectCommand="select pkid, username, email, creationdate from users"
DeleteCommand="delete from users where pkid = ?pkid"
UpdateCommand="update users set email = ?email where pkid = ?pkid"
If you read e-books regarding asp.net, the queries used are for MS SQL. It’s been a long time since I dabbled with MS SQL, so when I read about it, I thought the @ sign for parameters were required for any database used. Took me some time to know that ? has to be used. See the DeleteCommand and UpdateCommand properties of the SqlDataSource tag.
How you design your GridView control is up to you. With styles, you can override how the table would look like. The other GridView like control that I had used before that looks like asp.net’s version is the datagrid taglib for Java. The downside with using the taglib is that if your SQL query returns lots of rows, it may not load fast and may use up resources in doing so because it gets all records at one time. Asp.net’s GridView control totally impressed me in more ways.
These 3 technologies are the most famous these days in the web programming world. Sometimes you’d ask yourself, which of these 3 is the best? The answer, there’s none. It really depends on a lot of factors to decide which technology is best to use. In my experience, these are the following…
In the case of server setup, ASP would be easiest as installing IIS (Internet Information Server) is very easy. Just add this under add/remove programs, add/remove windows components and check the checkbox of Internet Information Services (IIS). Once the server installed, you can then place all your ASP pages under it default working directory c:\inetpub\wwwroot. I said ASP is easiest because you do not need to download the IIS installer. It is part of your OS installer so you can install it anytime. With JSP, you can download Apache Tomcat which is free. Installation is not a hassle and you then place all your JSP files right away under the server’s default webapp directory. Mostly when developers work with JSP, they are usually packaged as a web application archive file (.war). As for PHP, it’s the most hassle. There are so many things to configure before you can get PHP running. I use Apache HTTP Server for PHP but you would have to download PHP and configure its plugin to be used by the server to interpret PHP code.
In the case of language experience, if you already know VB/VBScript, quickest would be to go for ASP since it supports VBScript. If you know Java, then you go for JSP. If you know C, then PHP is for you. If you have patience to learn all of them, this is the order in which I rate each technology according to easiness: ASP/PHP (tie), JSP.
In the case of performance issues, there is really no clear winner for me. I’ve read a lot of articles that often compares the performance between these technologies. The secret for good performance is how well you design your system. If you messed it up real good, then good luck with your web application. And of course, you would have to have a fast server in order to process transactions efficiently, else the good design solution would be useless.
As far as I know, Servers for PHP do not have database pooling. As do ASP. If there are any now, please let me know. I’m pretty sure JSP’s server like Apache Tomcat supports database pooling because I have tried using it. I searched the same thing for PHP but could not find any in Google. Database pooling gives you a huge advantage on resource management. Click here to read more about it.
There may be other issues that need to be put into consideration when comparing these 3. For me though, these are it.