SQLite and .Net Part 3

October 17, 2009

Well after some more testing, I come to the understanding that the ALTER TABLE statement is rather limited in SQLite.

It seems a bit pointless then to use migrations…

I tried among other this:

Database.AddColumn(“Resource”, “Password”, System.Data.DbType.String, 50);

The SQL itself does not give any errors and the SQLite documentation says this should work. Absolutely nothing happened to my database schema.

This SQLite thing is giving me headaches :(

I’m still conviced that my idea to use SQLite for development (and in some cases for production) is a solid one. But truly being able to be completely database independant is proving not so simple.


SQLite3 and .Net Part 2

October 16, 2009

Owkay, so I really have a problem with my idea to use SQLite for development and MySQL for production.

It seems that composite primary keys cannot be added with the ALTER TABLE statement in SQLite. This is frikkin annoying to say the least.

Migrator.Net uses ALTER TABLE. Maybe I will look at the source code for Migrator.Net because it seems CREATE UNIQUE INDEX would do the trick and this can be used after creation.

I modified the SQLiteTransformationProvider class so it would use the CREATE UNIQUE INDEX statement (and uploaded it to google code) This did the trick.

Next hurdle: I need views in my app. I had this in a migration:

Database.ExecuteNonQuery(“CREATE VIEW vwProject AS “ +

“SELECT dbo.Project.ID, dbo.Project.Name, dbo.Project.CustomerID, dbo.Customer.Name AS CustomerName, dbo.Project.CompanyID “ +

“FROM dbo.Project INNER JOIN dbo.Customer ON dbo.Project.CustomerID = dbo.Customer.ID”);

It failed over the dbo. After removing the dbo it worked fine.

Mark Dec 15 in your calendar! Updated 4 hour workweek coming

October 16, 2009

SQLite3 and .Net. Do they play nicely?

October 15, 2009

For some time now, I’ve wanted to know what SQLite was all about. MySQL is fine and dandy, but for development, I always found it to be complete overkill. SQL Server Express for that matter too.

You will probably know I tend to script all my databases with Migrator.Net. Because Migrator.Net has a provider for both SQLite and for Mysql I can do my migrations locally for development with the SQLite provider and upon release migrate a MySQL database.

The only thing I will need to calulate in is the fact I will need a similar provider model for my Data Access Layer.

But… (there is allways a but…) I might have to write unit  tests for my providers.

Tonight I did some testing.

  1. I downloaded System.Data.SQLite from http://sqlite.phxsoftware.com/ but when trying to install it, I gave me an error that something else was already being installed. No, this was not the case… Second time I tried it, it worked
  2. I made a new solution in Visual Studio 2008 with two projects. One with the migrations and one that uses the database.
  3. For the migrations, I just copied a migration from an earlier project.
  4. Searched for a connection string to connect to SQLite, found it on http://www.connectionstrings.com/sqlite
  5. Ran the migration with:
    .\libs\migrator\Migrator.Console.exe SQLite “Data Source=.\SQLiteDatabase\Database.db;Version=3;” .\DBMigrations\bin\Debug\DBMigrations.dll
  6. In visual studio, I connected to the database.

IT WORKED!

Now I will try to use it in a real project!

UPDATE: I tried more and I got an error on a primary key constraint. It’s probably my lack of knowledge…


Find object dynamically in Generic List with List.Find()

October 14, 2009

Andrey Sanches has a very nice post here about how to use List.Find().

Notice that the search value is 1, which is a fixed value. That is not allways what you want. Consider for example you want to know if the person exists who’s id the user typed in a textbox…


Getting Things Done

October 14, 2009

Halfway trough Dave Allen’s Getting Things Done: The Art of Stress-Free Productivity. I’ve learned a few things I must say. Some I was doing already but reading about it makes you think. Just started the part on implementing the methods and practices.


An update on our WPF tryout

October 14, 2009

Well, In a previous post, I reported I started some WPF development for a new app. I had bought Sams Teach Yourself WPF in 24 Hours.

After some extensive testing we found that WPF was not the right technology for what we wanted to achieve. We decided to stick with ASP.Net.