Subject Problems using IB_Query and IBOQuery
Author aztoquetti
Hello everybody.
I've been using Firebird and IBObject for a few months. I'm still learning a lot about it. A litte time ago I was still using BDE.

I'm building a project in which I use IBObject 4.8.7 with Delphi 7, Firebird 2.1.2 and IBExpert 2008.

In IBExpert I created the database and a table called DEPARTMENTS. The fields in this table are...

Code - VARCHAR(10)
Description - VARCHAR(50)
Actually the var Code has to be VARCHAR, not INTEGER, because my program uses codes such as "123" and "12-3".

The table has these data...
Code Description
12-3 FINANCE
456 COMMERCIAL

I use the component IB_Query (or IBOQuery) to select records in the table, but some very strange things happen.
Although the field Code is VARCHAR, IB_Query does not work if contents of field Code contain characters that aren't numbers or the decimal point (.)

For example, if I have an EditBox, and I change its Text property to '12-3', and then I try to run the script...

IB_Query1.Close;
IB_Query1.SQL.Clear;
IB_Query1.SQL.Add('Select * from DEPARTMENTS where ("Code" = '+ edit1.Text +')');
IB_Query1.Open;

... when I try to run it, the following error message comes...


Project Project1.exe raised exception class EIB_ISCERROR with message 'ISC ERROR CODE:335544334
ISC ERROR MESSAGE:
conversion error from string "12-3"
'.Process stopped. Use Step or Run to continue.


Why the hell it tries to convert a string if the field is VARCHAR???

If, instead of "12-3", I change both value of field Code in table to "123" and the text in EditBox to "123", the script works.

This "VARCHAR" does not also accept alphabetic or special characters, only numerical or decimal point, as I said.

I've also tried to use CHAR instead of VARCHAR, and the same problem happens. As I said, the same thing happens when I use the component IBOQuery.

I need some urgent help because I have a few weeks to end this project.

Thanks since now.