Recent

Author Topic: Updated March_6 Source Code Project for database dev., using Lazarus with SQLdb  (Read 48031 times)

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
I am using lazarus-0.9.28.2-fpc-2.2.4-win32 (the stable version)
And there is no problem runnin in windows xp or 7 (on my computer)

However you have to understand that your using the unstable version, BUT the way I look at it?, Lazarus 0.9.29 has the correct procedure accessing ms_access.

Because in lazarus-0.9.28.2 the handling of tsqlquery.open and tsqlquery.close is not stable, as you noticed I've put the
Quote
There's a bug here(commented).
procedure TForm1.Button3Click(Sender: TObject);
begin
if SQLQuery1.RecordCount>0 then
  begin
  SQLQuery1.Delete;
  SQLQuery1.ApplyUpdates;
  SQLQuery1.Close; //ms_access bug, not needed with other connections
  SQLQuery1.Open; //ms_access bug, not needed with other connections
  Form1.caption := 'DELETED';
  end;
end;

And ONLY ms_access uses the SQL extension like deleteSQL, updateSQL, insertSQL


The other problem that you have, MAYBE you have set in the (object palette) TSQLtransaction properties to Active=true, WHILE in the code when it loads, it set the tsqltransaction.active to true.

Try to reset your components properties, dont change anything, because it was already set when the form loads.
 :D

thierrybo

  • Full Member
  • ***
  • Posts: 146
For the moment I just opened the project and ran it without any change, so SQLTransaction is false at design time. I use Lazarus SVN version because some months ago I tried some tests with ODBC against SQL Server 2008 and ran with bugs with the current version (0.9.28.2) that were almost all solved in the development version. But I never tried to use it with access.

I will try to play with this sample a little bit more. :)



xenblaise

  • Sr. Member
  • ****
  • Posts: 358
oh, the sample is very basic, it only views the basic sql transactions like add, delete, update using the component, but it can be done using the variable declaration.

SQLTransaction1.Active := True; //not applied to ms access(false)
Quote
So, it must be false
SQLTransaction1.StartTransaction;
Quote
BUT we need to initialized SQLTransaction to the Connection in order to communicate to the whole database design.
SQLTransaction was never used in Access Connection, as I noticed during a lot of testings.

Anyway I build very basic sample for some newbies.  Just like me asking for samples of lazarus database during my first day, and NOW Im always online to assist whatever I can do to help newbies and Lazarus.

We need a team work here, sharing information, codes and other tools to lift-up lazarus in this coming year.

And the way I look at it, next year will be one of the top programming software tools. :D
« Last Edit: October 26, 2010, 02:43:53 pm by xenablaise »

dkjMusic

  • Full Member
  • ***
  • Posts: 146
I'd like to contribute this code to all newbie of Lazarus Database development.
...
http://wiki.lazarus.freepascal.org/MS_Access
...
Are you still around to help with this? I am trying to get it running on Ubuntu 10.10 with Lazarus 0.9.28.2 and fpc 2.4.1.  :)
Windows 7 Ultimate/32 bit;
Lazarus 0.9.31/Rev 33300;
FPC 2.7.1/Rev 19464;
GDB 7.0.50;
(via CodeTyphon 2.30)

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
hi

I don't know if ms_access is accessible in Linux, but ubuntu is more near to Bsd, and probably they're the same can't see ms_access.

dkjMusic

  • Full Member
  • ***
  • Posts: 146
hi

I don't know if ms_access is accessible in Linux, but ubuntu is more near to Bsd, and probably they're the same can't see ms_access.

MS Access must be accessible in Linux because MDB Tools and Kexi work.

I got msaccesstest2 to run but I get an error when I Open the query which says "Duplicate fieldname: ''. Soooo close...

Any ideas or just give up?
Windows 7 Ultimate/32 bit;
Lazarus 0.9.31/Rev 33300;
FPC 2.7.1/Rev 19464;
GDB 7.0.50;
(via CodeTyphon 2.30)

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Quote
Duplicate fieldname

means,you,have,a,screwed,your,table.

dkjMusic

  • Full Member
  • ***
  • Posts: 146
Quote
Duplicate fieldname
means,you,have,a,screwed,your,table.
maybe,a,not.

I put a Query.Close just before the Query.Open and it worked like a charm (MS Access bug). Of course I had to also change numerous other items to get the thing to work (no DNS file, etc.).
Windows 7 Ultimate/32 bit;
Lazarus 0.9.31/Rev 33300;
FPC 2.7.1/Rev 19464;
GDB 7.0.50;
(via CodeTyphon 2.30)

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
:D
Yes, that's the bug, you don't have to put that in some data_model, except for ms_access,  but when I test back the code?, I removed the .close and .open <talking about record deletion>, it does work smoothly.  Something messy about using SQLdB ms_access.

In your case, that's really a bug, that's only for ms_access.

Try some other data_model like sqlite or firebird.
 :D

ramon

  • Newbie
  • Posts: 3
Quote
anyone requesting another sample? [October 19, 2010]

Could you share a sample of SQLQuery with Firebird?

Thanks.

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Ok,
We have SQLdB samples with;
Sqlite
Ms_Access
MySQL
and
Firebird as reguested <I'll post it later>

But Actually if you compare the codes from sqlite,msaccess,mysql?, they all look the same, the only difference is the sqldB connection.
Must see it.

JimBeam

  • New Member
  • *
  • Posts: 36
Ok,
We have SQLdB samples with;
Sqlite
Ms_Access
MySQL
and
Firebird as reguested <I'll post it later>

But Actually if you compare the codes from sqlite,msaccess,mysql?, they all look the same, the only difference is the sqldB connection.
Must see it.

XenaBlaise,

(Haven't looked at the code)
If the samples only differ a bit, couldn't you improve the samples by merging into one sample with the user's (either at compile or runtime) of database? That would neatly show cross-database programming, too!


xenblaise

  • Sr. Member
  • ****
  • Posts: 358
hi jimyX

Yes the code's are nearly same, please look at the codes.

Frankly, I tried it with FireBird, but seems I can't create a database, I've used flameRobin, but didn't work out.  I tried many, including, username with "SYSDBA" and password "masterkey".

I don't know where the problem is, no possible reasons erupt to my mine, maybe you can help.

Try to merge them including firebird.  Lazarus newbie users will be glad.
The sample links are shown in the beginning of the post. :D

JimBeam

  • New Member
  • *
  • Posts: 36
Ok, I'll have a look...

HowardH

  • New Member
  • *
  • Posts: 16
    • http://www.celtic-fiddler.com
I'd like to contribute this code to all newbie of Lazarus Database development.

Sample Source code project(.lpr) includes;
(source code at the bottom of the page)

SQLITE
(updated2_with_add_delete_update)
http://wiki.lazarus.freepascal.org/User:Rocarobin

Thank you for the example. I do have some questions about SQLite with Lazarus if you are still around. I am doing a migration of a small (7500 records in main table) PostgreSQL database to SQLite (so I can have a zero-config program) and I am having some performance issues. If you are around, please contact me or reply to this post.
Howard Lee Harkness
The Celtic Fiddler http://www.celtic-fiddler.com
Violins and Accessories

 

TinyPortal © 2005-2018