Saturday, 5 May 2007

Crystal Reports "Query Engine Error"

You want to create a report with Crystal Reports and you create that weird ADO.Net DataSet, then you add a Crystal Report, you select the tables you want from the created DataSet, then you drag the Id references to create the table links, you go through all that weird Report Expert, you add a Crystal ReportViewer to a Windows Form and you press F5! And you get "Query Engine Error".

Well, two main reasons for this are explained in this nice article: "Query Engine Error" With Crystal Reports .NET, but you just created the report, there is no way you changed the XSD or the name of the tables.

I tried a lot of things until I found out what was going on. You see, I had this tables that had an "Id" column and a many-to-many table that had "UserId" and "MenuId" columns. In order to link them, I did what I also did in the XSD, I dragged the Id (primary key of each table) to the UserId and MenuId columns. That was the problem! You have to do it the other way around, drag the Foreign Key columns to the Primary Key columns.

Hopefully, you would have read this article before wasting hours to find out what the hell is that error and where it comes from... It happened to me with Crystal Reports 9.0 and Visual Studio 2003.

Oh! And don't bother to link the tables in the DataSet XSD, since Crystal Reports seems oblivious to that.

Crystal Reports - Insert Field is disabled

I am working on this windows app that uses Crystal Reports. I've never used it before and I thought "Hey! I could learn something new". So I opened this .rpt file in Visual Studio 2003 and I got the most incomprehensible interface ever. I mean, I will have to invest some hours just to understand what the report interface is all about.

But anyway, I thought I would take an existing report and then just change something, like adding a new field. I went with the mouse on an empty space, right click, context menu, Insert... I could insert text. I could insert Special Fields (report data like number of the page, creation date and so on). I could insert Fields. Only that option was disabled! I've tried every option in the context menu, no avail.

Finally I've decided I am to dumb to figure it out, I went to man's best friend: Google! The answer found in an obscure forum was:
- Go to View (in Visual Studio 2003)
- click Other Windows
- click Document Outline

Now a Field Explorer window is open and I can see all fields and drag them to the report. That was it! :-/

Escaping Regex replace patterns

When one wants to replace a text, say, case insensitive, one uses the .NET Regex class. In order to make sure the text to be replaced is not interpreted as a Regex pattern, the Regex.Escape method is used. But what about the replacement string? What if you want to replace the text with "${0}", which in Regexian means "the entire matched string" ? You need to somehow escape the replace pattern.

I have no idea where to find this information on MSDN, although I am sure it is hidden somewhere in all that Regex labyrinth. Here is the link on MSDN: Substitutions

So here is the info: You only need escaping the dollar sign, so the code would look like this:

Regex reg=new Regex("Text to replace",RegexOptions.CaseInsensitive);

string s="here is the text to replace";

s=Regex.Replace(s,"$${0}");

Now the value of s is "here is the ${0}".

Mitsubishi Colt is our final (hopefully?) choice!

Yes, we went to the Mitsubishi dealership. It was nice to actually have someone talk to us and give us all the details, thing that did NOT happen to us at any showroom except the Seat part of the Skoda showroom.

As a side note, I tried entering the Pajero, the Mitsubishi SUV and... I couldn't fit. Not even a tortured position. The front seat moves electrically (yes, some people are so lazy that moving their own seat takes too much. My foot was turned at 90 degrees, my leg could not find a proper position and it wouldn't pass past the steering. It was horrible. But then it dawned on me: tall people don't buy SUVs! The usual suspects when we're talking SUV drivers are fancy women and small, fat people. You don't buy an SUV because you need it, but because it compensates for some shortcomings (pun intended).

Now, back to the car we preordered!! The Mitsubishi Colt is a normal droplet shaped hatchback. But I could fit in! A little effort was required on the driver's seat, but it was ok. More than that, I am sure the rails of the seat can be lengthened or at least moved a little back. The back seats also move back! You can also collapse them or even remove them entirely, giving a huge space in the back if there are only one or two people in the car. It also has automatic gear shifter, which is terribly difficult to find in small cars (or any cars for that matter) in Romania; yet, unfortunately, only the gasoline car models. No matter. I was looking for a gasoline car anyway. The color choice was rather poor, I had to choose between white, black, gray and red nuances.
carmine Mitsubishi Colt
So, we preordered the car! A carmine Mitsubishi Colt Hatchback, 1.3 Gasoline, Automatic/manual gearbox (that means you can switch between them whenever you like).

Now, all we have to do is get the money (from a bank!) and pay a lot of money every month for 5 years. Wish us luck!

Thursday, 3 May 2007

Tuesday, 1 May 2007

Ban water! It's eeeeevil!

No, I am not talking about Dark Water, either. I am talking about water. Penn and Teller went to a rally of some sort and asked people to ban dihydrogen monoxide; water, that is...



So, if you are reading this, dear environmentalists and conspiracy theorists... don't listen to everything that sounds good, because most of it is not, even if it seems to enter the same agenda as yours...

The holograms are here!

A while ago I wrote this entry about an innovation in sound technology that will probably change the way we think of sound.

Today I am presenting a video technology I witnessed at the mall! Yes, the mall, that dreaded place of overpriced junk and overdressed bimbos. Overpriced, too! :) Anyway, I was watching this Pepsi commercial on a big TV like device, where a can of Pepsi was rotating showing its full cylindrical glory. Only that it felt out of focus. My eyes were kind of sore watching it. Immediately the image changed to a ball that came towards the screen and then... went through the screen!

It worked from almost every angle, without being a holographic thing in the middle of the air, but more of an optical illusion. Thinking of the faithful thousands of people reading this blog every day, I remembered the little link on the side of the device: www.x3d.com, with their device called MultiView.

The image is not as clear as one would want. It's like continuously vibrating or something like that, but the optical illusion is great! I saw people passing by the device and trying to put their hand through the "flying" objects.

Here are a few links from Wikipedia about the subject:
Volumetric Display
Autostereoscopic