Home | Blog | Publications | Photos | Services | About | Contact

Blog Archive - November, 2004

Back to Blog index.

Mon, 29 Nov 2004 16:22:24 GMT:
Delphi 2005 debugging launch bug

I found a bug with Delphi 2005 today, and it occurs when I create and .NET application and the destination output directory contains non-ASCII characters in it's name.

If this happens, the error message on Run/Run (the F9 key) is merely "Unable to create process", which is somewhat unhelpful.

The workaround is to change the output directory (or the project's directory) so that it doesn't contains characters like Ä, Å or Ö.

This incident has been reported to Borland's QualityCentral with the report number 9660.

Fri, 26 Nov 2004 15:06:15 GMT:
Dreamweaver and ASP.NET pages

One of the major ASP.NET applications I'm building uses XHTML for cleaner formatting and standard awareness.

Also, the site has been built with Macromedia Dreamweaver, and template files are in heavy use (which is good).

But, since many of my ASP.NET pages are quite complex, and a change to the Dreamweaver template needs to be made, the changes make the ASP.NET pages invalid.

I'm still to investigate this, but the ASP.NET pages do still compile and run after the template has been changed, but all the controls that run on the server are missing.

If you are using the same combination as I am, make sure you don't fall in the same trap, will you?

Fri, 26 Nov 2004 04:30:07 GMT:
Don't forget about ExecuteScalar

I guess my Wednesday post was made too late in the day for I had totally forgotten that I don't need to use a DataReader when I'm only reading a single value from an SQL query. Duh.

Naturally, the easy to do such a thing (like reading a generator value) is to use the ExecuteScalar method:

Try
    SQLQuery := Borland.Data.Provider.BdpCommand.Create();
    SQLQuery.CommandText := 'SELECT GEN_ID('+GeneratorName+',1) FROM RDB$DATABASE';
    SQLQuery.Connection := Borland.Data.Provider.BdpConnection(IBTrans.Connection);
    Result := System.Int32(SQLQuery.ExecuteScalar());
  Finally
    ...
  End;

Now, who said the returned generator value was a System.Decimal? Not anymore, it seems! Humans learn by doing...

Wed, 24 Nov 2004 15:15:43 GMT:
BDP.NET and InterBase generators

A Delphi application I'm developing uses an InterBase 7 database, and in that application, I need to have a simple, auto-increment counter value.

Naturally, the best way to do this with InterBase is to use generators, and then query their values using simple SQL statements like these:

SELECT GEN_ID(MyGenerator,1)
FROM RDB$DATABASE

Previously, I've used the TIBSQL component (in Win32) to query the values, and in these cases the type returned by the component has been a 64-bit integer, i.e. an Int64.

But since I've moved almost exclusively to .NET programming, I don't want to use these components anymore, but instead the BDP.NET components, or Borland Data Providers that are compatible with ADO.NET.

So, a BdpDataReader (from the Borland.Data.Provider namespace) is a good choice to read generator values, but to my surprise the value returned for the generator is not an integer value, but... a... System.Decimal!

Oh well, something's gone wrong here, but luckily the situation is easy to fix. Just read the generator value as a decimal, and then use the ToInt32 or ToInt64 static methods of the System.Decimal structure to read the value as an integer.

For example, like this:

DataReader := SQLQuery.ExecuteReader();
Try
  If (DataReader.Read()) Then Begin
    MyGenValue := System.Decimal.ToInt32(
      DataReader.GetDecimal(0));
  End;
Finally
  DataReader.Close();
End;

This is my today's tip for anybody who is trying to solve the same issue!

Fri, 19 Nov 2004 05:09:23 GMT:
Purple Motion surfaces again

If happened to watch the Finnish computer demo scene in the early '90s, you might have heard of the group called Future Crew.

They made great demos, and also had excellent music tracks to them, thanks to a guy dubbed Purple Motion. For example, I find myself often listening to his songs "Aquaphobia", "Insideout" and "World of Plastic", even in 2004.

Now, the long-extinct crew is back, and they have a web site, too. From there, you can purchase their music on a disk.

It's fun to see this site after all these years.

Thu, 18 Nov 2004 16:33:41 GMT:
SQL Server 2005 programming

MSDN has a good document about SQL Server 2005 CLR programming.

It was especially nice to see how you can convert for example XML data back to tabular database format.

Wed, 17 Nov 2004 17:01:31 GMT:
Delphi 2005 is here

I got my copy of Delphi 2005 today, and installed it. It's long since I needed to change disks while installing Delphi! There are three CDs now, where you usually need only two.

It's still too early to report about the new features, but two small things I like are the ability to have Code Completion when editing HTML/CSS files, and the shortcut key Ctrl+/ to comment and uncomment a line in code.

More reports to follow...

Thu, 11 Nov 2004 16:22:17 GMT:
Newest Tietokone has my SP2 article

The November issue of the Tietokone magazine published my newest article, "Näin otat Windows XP SP2:n käyttöön". It was also mentioned on the front cover, which is nice.

The article is a two-pager and discusses how an organization might best install and distribute Windows XP Service Pack 2 using Microsoft's software deployment solutions.

Wed, 10 Nov 2004 16:52:33 GMT:
A simple way to log data to a text file

I thought I'd share my simple piece of .NET Delphi code, as the code is often useful, but never at hand when needed.

The idea is that, for instance, in ASP.NET application it is difficult to know when things go wrong. For that reason, some logging is needed, and the simplest way to do this is to write the exception object data to a file.

But to write text to the file is the question. What is the simplest way to do it? I think the following procedure is quite likely it:

Procedure LogMessageToFile(Msg : String);
Var
  SW   : System.IO.StreamWriter;
  Text : String;

begin
  SW := System.IO.File.AppendText(
    'C:\Temp\logfile.txt');
  Try
    Text := System.String.Format(
      '{0:G}: {1}.',System.DateTime.Now,Msg);
    SW.WriteLine(Text);
    System.Console.WriteLine(Text);
  Finally
    SW.Close();
  End;
end;

Mon, 08 Nov 2004 16:53:20 GMT:
Piano chords

I've been looking to find information about piano chords from the Internet, but so far I've only found impartial or alltogether commercial material.

Now, two links saved my day, and I was able to have some decent background sounds to my synth samples.

The links are these:

http://www.danmansmusic.com/chords.htm

http://www.cumpas.co.uk/piano.php

Enjoy!

Sun, 07 Nov 2004 16:37:57 GMT:
A literature study helper

I enjoy reading classic books, and just lately I've finished Wuthering Heights from Emily Brontë.

As with many classic books, the characters are many, and the wording complex, and as I'm often reading the books weary of the day's duties, sometimes the characters and their relations escape me.

Luckily, there's a web site from Barners & Noble called SparkNotes which hosts a literature study guide.

From there, you can pick any of those classic books, and read their plot, have a list of the characters, and also read the actual texts of those books.

Now I don't need to despair anymore who was who's daughter-in-law or late husband anymore.

Sat, 06 Nov 2004 12:25:32 GMT:
SQL Server unit testing

I've heard that unit testing is useful for application development, but the new thing to me was that there are unit tests for database data, too.

Henrik Ekelund has written a T-SQL Unit test framework for your SQL Server databases. In the unit testing spirit, this utility is available in open-source format at SourceForge.

I still have to convince myself of the usefulness of unit testing for database data, but nonetheless, it's good to know that something is available if you or I get interested in it.

Sat, 06 Nov 2004 10:28:46 GMT:
Visual Basic .NET coding

I helped a friend of mine to get started with an ASP.NET web application. My friend doesn't know C# which I prefer, so we chose to use VB.NET.

Since I haven't used VB.NET much at all, I had to refresh my memory how the language syntax went. But the good thing was that I've been using ASP.NET quite a lot with both C# and Delphi, so luckily, I had that knowledge on my side.

In addition to learning some VB.NET stuff, it once again wonders me how much power the .NET framework can give you as a developer, since you can use your skills in the framework no matter which programming language you choose.

After that, it isn't much else than just language syntax. And, the ASP.NET QuickStart Tutorials help here a lot.

Thu, 04 Nov 2004 05:44:06 GMT:
Watch your connection strings!

I had to migrate one ASP.NET application I had written with Delphi 8 to the newer version of Delphi, Delphi 2005 in fact.

I've been using a late beta version of Delphi 2005, and when I compiled my application with the new version and ran the application, all I got were error messages similar to these:

The located assembly's manifest definition with name 'Borland.Data.Interbase' does not match the assembly reference.

Exception Details: System.IO.FileLoadException: The located assembly's manifest definition with name 'Borland.Data.Interbase' does not match the assembly reference.

Or:

File or assembly name Borland.Data.Interbase, or one of its dependencies, was not found.

Exception Details: System.IO.FileNotFoundException: File or assembly name Borland.Data.Interbase, or one of its dependencies, was not found.

First, I thought that this was a beta issue, and thought that maybe building a test application would show me where the problem was. But, my test application got flawlessly it's connection to my InterBase database, and so I knew the problem was in my application, not in Delphi itself.

I checked the version of the Borland.Data.Interbase.dll assembly on my PC, and found it be version 2.0.0.0, when my application was requesting a version 1.5.1.0, which obviously wasn't found.

I tried to search high and low for this reference, but couldn't find anything. But finally, I checked my connection string (in this application I create every component in code), and there it was! I didn't recall that my ADO.NET connection string held the version of the required DLL, and this is where my application got the idea to search for an earlier version of the DLL that came with Delphi 8.

Today's lesson: if nothing else helps, check yer connection strings!

Mon, 01 Nov 2004 16:17:53 GMT:
System.Collections.SortedList and sorting

I was writing a Delphi .NET application today where I need to sort strings. Of course, my favorite for simple situations is the System.Collections.SortedList class, and this is what I also used today.

With it's easy operation, I'm able to sort strings and also associate data with the keys. But, today I noticed that the default sorting for strings assumes that the letters V and W are the same. However, this is not the case in Finland -- those letters are and should be different.

According to the Framework documentation, the SortedList class uses by default "the IComparable implementation provided by the keys themselves", which in my case means System.String.

Now, being aware of .NET's support for cultures, I thought that maybe the default for sorting was something like the U.S. based sorting (as often happens), but indeed it was not. Instead, the System.Threading.Thread.CurrentCulture.Name member returns the correct culture for this northern land: "fi-FI".

Having limited time to solve this puzzle, I decided to go the easy way, and specify another IComparable implementation to the constructor of the SortedList class. So, my tip for today follows.

To get things working the Finnish way (i.e. V and W being different), I just constructed the object like this:

procedure PageGen.GetList();
Var
  List : System.Collections.SortedList;

begin
  List := System.Collections.SortedList.Create(
    System.Collections.CaseInsensitiveComparer.DefaultInvariant);
...

As you can see the DefaultInvariant static property of the System.Collections.CaseInsensitiveComparer class is the key here.

 

› Blog Archive