woensdag 3 oktober 2012

Trace in SQLite. SQLiteTraceEventHandler

To activate Tracing in C# in Sqlite, there is a trick. The connection must be open.

 conn.Open();
 conn.Trace += new SQLiteTraceEventHandler(this.SqliteWriteLog);
 conn.Close();

        private void SqliteWriteLog(object sender, TraceEventArgs e)
        {
            File.AppendAllText("c:\\sqlitelog.txt", e.Statement+"\r\n");
        }

zondag 30 september 2012

Firebird embedded database

Today, I tested the possiblity to use the embedded Firebird database in my movie application.

The negatives I've found this far:
1) Firebird has no autoincrement fields. Just like oracle, you need to create a sequence/generator.
2) There are a lot of reserved words in Firebird, like "Character". To delimit the keywords, use double quotes. The columns can be best in uppercase, because then you can also access the columns without quotes.
3) "drop table if exists.." does not work.
4) DML and DDL cannot be used together. This complicates the creation of sql scripts.
5) Many DLL's are needed to run the embedded database. 7 MB at minimum. This is much more than Sqlite.

update 3-10-2012: Firebird is much slower than Sqlite. It was nice to test with Firebird, but as an embedded database, it is too slow. And it misses a lot of handy's because it is too old...

donderdag 16 augustus 2012

Kubuntu on Virtualbox

The installer of Kubuntu is pretty smart, so when you define your wanted network situation before installing Kubuntu, everything will be working.

My best situation is not "bridged network" because when you unplug the networkplug, you cannot connect to your local network anymore. This is an unwanted situation for me, because I want always be able to connect to my local network.

My best situation is two network adapters:
1) Host-only Adapter
2) NAT
Both with default settings.

Set these two in your Virtualbox settings before you install Kubuntu and while installing Kubuntu will recognise them.

The screen resolution is default not recognized by Virtualbox. You need to do the following:

> open a console on kubuntu
sudo apt-get install dkms
> sudo apt-get install build-essential

This installs the build-system, so that the guest additions are correctly compiled.
After this install the guest additions (apparatenbeheer). Click the "autorun.sh".
Reboot the system, and everything works.

While busy, you might want to install chromium:
> sudo apt-get install chromium-browser

maandag 18 juni 2012

SQLServer collation


ALTER DATABASE database COLLATE Latin1_General_CI_AS

SELECT
 [name]
 ,COLLATIONPROPERTY([name], 'CodePage') AS [CodePage]
 ,COLLATIONPROPERTY([name], 'LCID') AS [LCID]
 ,COLLATIONPROPERTY([name], 'ComparisonStyle') AS [ComparisonStyle]
 ,COLLATIONPROPERTY([name], 'Version') AS [Version]
 ,[description]
FROM ::fn_helpcollations()
where name like 'Lat%'

zaterdag 17 maart 2012

Force a breakpoint in C# code

When you close your solution, your breakpoints are gone.
You can also use the statement  Debugger.Break(); to force a break in C#.

donderdag 23 februari 2012

Soft hyphen in iText

The idea of soft-hyphens are not supported in iText 5.1.3. Soft-hyphens mark the spots where a word can be hyphenated. So when a word contains soft-hyphens and is at the end of the line, the word-processor can break the word and the soft-hyphen is shown at the end of the line.

iTextSharp, which is a fine C# opensource PDF generator, does not support soft hyphens and just shows all soft-hyphens as hyphens in the PDF.
When you do not want any hyphenation, you can replace the soft-hyphen, “\xad” with “” before sending the text to iTextSharp.

But in my case, I wanted to use hyphenation and the soft-hyphen idea, so I changed the code of iTextSharp 5.1.3.
And it was not so complex!  First I added a few codelines in the PdfChunk.cs file. The second thing I needed was a manual hyphenation class which determines what is the best place to hyphenate a word. Ofcourse I used the soft-hyphens to determine that.

Here http://www.godzoeker.nl/_nietweg/iTextSoftHyphen20120223.zip you can download a zip which contains the modified PdfChunk.cs and the original PdfChunk.cs so you can see the differences. And the manual hyphenation class is also included.