Tuesday, November 27, 2007

My(SQL) stupidity

What happened is this: I had a MS-Acces DB which I transported to MySQL on 'Windows'. Now, the migration toolkit decided that it will NOT preserve the case of the tables - since this is Windows. OK - I ran my School Administration System and tested it on MySQL on Windows. Worked fine. Now, I decide to move the database to my server, and here is where it all started.
First, MySQL on Linux wouldn't let me connect to it from my workstation - no privileges. Fine. I used the MySQL Administrator to add the user, grant it privileges through the Global Privileges (you got to turn the Global Privileges on in Tools->Options).
That done, I ran my program. However, this time, I got the same error - username not authenticated. I wondered and wondered why. Then it struck me like lightning. O D B C !!!
Vb.Net uses MySQL ODBC connector, to connect to the database. This System and User DSN was configured to connect to my LOCAL machine, and not the SERVER! Damn damn damn!
I changed that, and viola! Things started running! Well, almost.
Now, VB.Net starts throwing exception after exception. No table this, no table that. I'm like - you cannot be serious. I see these tables, I see data in them, then why the heck won't you see them? Another bolt of lightning. C A S E! Damn damn damn. After cursing myself and the migration toolkit, I started looking, though sadly, for this parameter to be included in my.cnf: lower_case_table_names. I set this level to 1, so that MySQL will ignore the details about case-sensitivity. Yes, I will not keep my tables case sensitive from now on. But its too much work to rename all the tables in my VB.Net code.
Anyway, its up and running like a champ - so it seems for now. I'll put up any more issues that I see from here on.

Sunday, November 18, 2007

Moving from MS-Access to MySQL in VB.Net

I have a School Administration System , written in VB.Net, which used MS-Access. Needless to say, that was a bad decision. OK - a very bad decision. Finally, I decided to move out to MySQL. Why MySQL? Well, because my server is set up to be Linux, and I wanted all the data on all the computers to come from one place. So, first, I read up the whole of www.vbmysql.com, without which I would still be wondering about where to start from. Mike Hillyer has done an excellent job in putting that website together.

Saturday, November 17, 2007

Deleting data from all tables in MySQL

Why would I need it? Well, I am in the process of transitioning from Access to MySQL, thats why. The porting process is slow, and data keeps getting added to Access. So I figured out a way to clean old data from MySQL tables.
At the mysql prompt:
mysql> use dbName;
mysql> show tables;

**get a list of tables here**

Select the table names and paste it in your editor of choice. Add "delete from " to the beginning by running a regular expression search and replace operation for the special character ^. Thats it! You have a list of delete statements, which you can just copy paste at the MySQL prompt.

Sunday, November 11, 2007

AJAX and PHP

Yes, yes I know - an article on AJAX and PHP AGAIN? Well, to be frank, I think this entry will help for a beginner in understanding how to and where to begin when (s)he wants to start developing web applications.
I know that I am *quite* late in hopping on to the AJAX and PHP bandwagon. I have done a lot of Javascript and DHTML work, I have done a lot of PHP work (long long time ago in 2001). So let me set the requirements here. Steps to learning PHP and AJAX are:
1. Before you start learning about AJAX, you need to know what JavaScript and DHTML is. Start by building simple client only web pages based in JS and DHTML.
2. Once you do that, throw in some XML. This is where it gets a little complicated. XML, XSLT, XSL and who knows what. There is no end to it. Anyway, I think its best if you do some XML and some XSL and then using JS to parse the XML.
3. Now, you need to enter the world of PHP and server side scripting. You have to be very clear about how communication happens between the browser and the server, what is meant by HTTP requests and responses. Then, start by writing small PHP scripts which will communicate with the browser and show and take some data. In short, go about learning PHP the traditional way, that is, without AJAX in the mix. ( I am skipping setting up LAMP ). PHP.net has a tutorial for beginners, and so does Google.
4. Once you do that, go to the Mastering AJAX series, and read up. Its an excellent series of articles, which will help you get a grip on what AJAX is all about. Well, this is where I am currently at. I will update on more links once I do some more snooping around.

Wednesday, November 7, 2007

The Future of Food

I have been thinking of this thing for a long time. Scientists working on combining various food materials to check their compatibility for the tongue and nose. PopSci, now has published an article which explains in detail, of how such things are taking place - Genes, nose, tongue, brain - the works. An excellent article for people who want to know the technicalities of good food!