[Lazarus] [lazarus] Advice about creating database-aware application with Lazarus

Howard Lee Harkness howard.lee.harkness at gmail.com
Sun Jun 22 04:06:52 CEST 2008


Well, I couldn't just give up, I had to try ONE MORE THING.

So, I put in the following code:

procedure TForm1.DBNavigator1Click(Sender: TObject; Button:
TDBNavButtonType);
begin
  case Button of
  nbPost: begin
          SQLQuery1.DisableControls;
          SQLQuery1.ApplyUpdates;
          SQLQuery1.EnableControls;
          end;
  nbRefresh: begin
             SQLQuery1.Close;
             SQLQuery1.Open;
             end;
  end;
end;

At that point, I could insert a record, but not edit or delete a record. So,
I tried the following:

procedure TForm1.DBNavigator1Click(Sender: TObject; Button:
TDBNavButtonType);
begin
  case Button of
  nbDelete,
  nbPost: begin
          SQLQuery1.DisableControls;
          SQLQuery1.ApplyUpdates;
          SQLQuery1.EnableControls;
          end;
  nbRefresh: begin
             SQLQuery1.Close;
             SQLQuery1.Open;
             end;
  end;
end;

Lo, and behold! I could now insert a record, and delete a record!!! Elated,
I tried the following:

procedure TForm1.DBNavigator1Click(Sender: TObject; Button:
TDBNavButtonType);
begin
  case Button of
  nbDelete, nbEdit,
  nbPost: begin
          SQLQuery1.DisableControls;
          SQLQuery1.ApplyUpdates;
          SQLQuery1.EnableControls;
          end;
  nbRefresh: begin
             SQLQuery1.Close;
             SQLQuery1.Open;
             end;
  end;
end;

Alas, no joy. I can insert and delete a record, but I still can't edit a
record.

I don't know if I can send attachments to this list, but if I can, the
source for the trivial application is attached.

The schema for the table I'm using is:

CREATE TABLE IF NOT EXISTS ZIPCODE
(
 ZIPID INT NOT NULL AUTO_INCREMENT,
 ZIP VARCHAR(5) NOT NULL,
 ZIPEXT VARCHAR(4),
 CITY VARCHAR(40),
 STATE VARCHAR(2),
 PRIMARY KEY(ZIPID)
);
INSERT INTO ZIPCODE (ZIP,ZIPEXT,CITY,STATE) VALUES
 ('01814',NULL,'Lawrence','MA')
,('13502',NULL,'Utica','NY')
,('22030',NULL,'Fairfax','VA')
,('27030',NULL,'Mt. Airy','NC')
,('27103',NULL,'Winston-Salem','NC')
,('27104',NULL,'Winston-salem','NC')
,('27106',NULL,'Winston-Salem','NC')
,('30084',NULL,'Tucker','GA')
;

On Sat, Jun 21, 2008 at 7:35 PM, Howard Lee Harkness <
howard.lee.harkness at gmail.com> wrote:

> Yes, I'm using XP Pro SP2.
>
> Knowing how to configure Lazarus is not useful unless I can write a program
> that works using it.
>
> I went back and checked to see if maybe I did the FPC installation without
> the default configuration file. Nope. It is checked by default, and I didn't
> change it. This time, I went through the readme and verified that I could
> build and run the Hello, World program. I was careful to install it directly
> to the directory where Lazarus would find it.
>
> This time, I got a different error on the LCL build: Error: Identifier not
> found "LowerCaseTable".
>
> That's it for tonight. Since my time is worth more than minimum wage,
> Lazarus is getting too expensive. I don't like admitting to defeat, but this
> one has defeated me.
>
> I think I might have an old copy of D2, D3 or D4 somewhere... and maybe
> even a copy of D6. I know that I can make any of those do what I want, even
> if I have to go back to using the old BDE.
>
> No, I don't care what database is underneath. No, I don't care if it's
> cross-platform. No, I don't even care what language it's written in (I am
> familiar with over a dozen), as long as I can make the app work. And if it
> can't be made to work, it doesn't matter what the database is, or whether
> it's cross-platform, or even what the language is. The ONLY thing that
> matters to a working programmer is whether the stuff he writes WORKS.
>
>
> On Sat, Jun 21, 2008 at 7:26 PM, Felipe Monteiro de Carvalho <
> felipemonteiro.carvalho at gmail.com> wrote:
>
>> 2008/6/21 Howard Lee Harkness <howard.lee.harkness at gmail.com>:
>> > At this step: Go to Tools --> Configure build lazarus
>> > I get the error: Fatal: Can't find unit system used by AllLCLUnits
>>
>> I just tested here and it works for me. I don't know what is
>> different. Maybe you unchecked "create default configuration file" in
>> the fpc installer.
>>
>> Are you using Windows XP too?
>>
>> > At least I was able to get 2.2.0 to restore. However, I'm back where I
>> was
>> > before: A trivial 1-hour project has taken nearly 20 hours over a period
>> of
>> > 3 weeks, and I haven't got anything to show for that effort. I'm tired
>> of
>> > this.
>>
>> If you focus in the positive side, you learned a lot about how to
>> configure lazarus =)
>>
>> Also, the original answer by Joost was:
>>
>> "You can find this problem in the bug-tracker. You can work around it
>> with 'TDataset.DisableControls' and 'TDataset.Enablecontrols' around the
>> applyupdates call. Or try fpc 2.2.2rc1 or any later version."
>>
>> So instead of trying to configure Lazarus with FPC 2.2.2rc1 you coul
>> just have used TDataset.DisableControls ...
>>
>> > to work on this for the week, so I think I'll stop by Fry's on the way
>> home
>> > from work sometime next week and buy a copy of Visual Basic. Bet it
>> won't
>> > take me 20 hours to write a trivial DB app in VB.
>>
>> It surely won't be cross-platform, nor will it support unicode =P Also
>> it's probably a bad choice, as VB will probably wish that you use
>> Access instead of MySQL (unless you don't care about which database to
>> use).
>>
>> But I do agree that Lazarus needs to improve when it comes to
>> developing database aware applications.
>>
>> With the money from VB you could pay someone to fix all problems with
>> lazarus database apps connecting to mysql =P
>>
>> I would go as far as saying that the only case in which I would
>> recommend for someone to use Delphi instead of Lazarus is if he is
>> developing Windows-only data-aware applications and he doesn't need
>> any of the other features of Lazarus (like being open source,
>> supporting unicode, etc).
>>
>> --
>> Felipe Monteiro de Carvalho
>> _______________________________________________
>> Lazarus mailing list
>> Lazarus at lazarus.freepascal.org
>> http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
>>
>
>
>
> --
> Howard Lee Harkness
>



-- 
Howard Lee Harkness
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20080621/a2ac1e81/attachment-0007.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zipform.pas
Type: application/octet-stream
Size: 1268 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20080621/a2ac1e81/attachment-0028.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zipform.lfm
Type: application/octet-stream
Size: 1696 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20080621/a2ac1e81/attachment-0029.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zipproject.lpr
Type: application/octet-stream
Size: 343 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20080621/a2ac1e81/attachment-0030.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zipproject.lpi
Type: application/octet-stream
Size: 4172 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20080621/a2ac1e81/attachment-0031.obj>


More information about the Lazarus mailing list