Tuesday, July 21, 2009

SQLite and AIR

So, I am spending some time, playing with AIR and the built in SQLite database. I am working on a small project that is for my benefit, but hey, I may share it later on :)

Anyways, last night I was going through the examples on Tour de Flex, and I am the kinda guy that learns by example, so I just copied the code that was there, modified it for my liking, and then tried to run it. I continually got the 1009 error, you know the not really telling you what is wrong error.

Anyways, after a quick Twitter talk with Andy Matthews, Jason Dean and Simon Free I changed the extension of the SQLite database to something other than the .DB that was in the sample code.

Now, with further discussion, it seemed like this was something of a rarity, and no one seemed to know why it wasn't working. (i.e. a .DB extension worked for Jason, but not me, Andy had issues with the .DB extension at a point) It just really seemed odd.

So, I went a little deeper. It seems that if you already have a .DB extension registered on your computer, you cannot make the SQLite database use that extension! This causes some concern I would imagine for installing programs on certain computers. Who knows what kind of extensions ppl have registered. Of course, as Jason tested, you can make ANY extension for your SQLite database.

So, if you are having issues with creating your first ever SQLite database, this may be the problem, however un-illuminating the 1009 error is. All of my AIR programs are going to use the agfusion extension for their database... so you should come up with your own.

**After some further testing, it seems that it is not just due to the fact that the file is already registered, but more due to the fact that there are no actions associated with the file type.

If you go to Windows Explorer > Tools > Folder Options > File Types, you can see what actions are associated with each file extension, by selecting the file type and then hitting on Advanced. Now for me the .DB extension had no actions associated with it, due to, well who knows. Anyways, I guess the point is, is that it really should work, but I am still keeping my unique file extension, to make sure that it doesn't.

In the Ag industry there are programs that already use the DB extension (as witnessed) and if I am making an AIR app to do something, it needs to work regardless of what might have already happened to a system, so I will play it on the safe side!

1 comment:

  1. You should post up some sample code. I have an app in mind that I want to use this for. I also can't wait for the CF9 auto magic sync :)