AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Arbeiten mit SQLite

Ein Thema von CalganX · begonnen am 14. Okt 2004 · letzter Beitrag vom 24. Okt 2004
Antwort Antwort
CalganX

Registriert seit: 21. Jul 2002
Ort: Bonn
5.403 Beiträge
 
Turbo Delphi für Win32
 
#1

Arbeiten mit SQLite

  Alt 14. Okt 2004, 15:51
Hi,
ich versuche jetzt mit SQLite über die Komponten von Aducom zu arbeiten. Notgedrungen sozusagen, weil die Datenbank mir vorgegeben ist.
Ich versuche jetzt einfach mal eine Liste zu erstellen, wo Informationen in einer Tabelle dargestellt werden.

Beispiel: in der Tabelle artistTable steht einmal das Feld iArtistId und das Feld cArtistName. Soweit so gut. Wenn ich die Tabelle angezeigt bekomme, wäre ich schon weit. Ich habe das versucht, wie in einer Demo mit Hilfe eines DBGrids und einem DataSource, aber leidet wird nichts angezeigt.
Allerdings würde ich gerne einen Schritt weitergehen, denn in der Tabelle songTable stehen die wirklich interessanten Dinge drin, dort gibt es zum Beispiel das Feld iArtistId, die verbunden ist (nicht direkt, sondern es sollte so sein) mit dem iArtistId aus der Tabelle artistTable. Jetzt möchte ich gerne in einer Liste folgendes anzeigen: in der Liste sollen alle Einträge aus songTable stehen und die ganzen Dinge die da drin stehen (z.B. iArtistId) sollen aus den entsprechenden Tabellen rausgeladen werden.

Mit MySQL unter PHP würde ich das schaffen, aber ich habe keine Peilung, wie man das unter Delphi macht. Die genannten Komponenten sind wohl ebenso aufgebaut, wie die gesamten anderen Datebankkomponenten, die schon dabei sind. Also ich denke dass dort nicht das Problem liegen sollte.

Wenn mir das jemand mal erklären könnte, wäre sehr dankbar.

Chris
  Mit Zitat antworten Zitat
CalganX

Registriert seit: 21. Jul 2002
Ort: Bonn
5.403 Beiträge
 
Turbo Delphi für Win32
 
#2

Re: Arbeiten mit SQLite

  Alt 14. Okt 2004, 19:13
Hi,
den ersten Schritt (Tabelle anzeigen) habe ich hinbekommen. Das mit der Reihenfolge der Zuweisung mit TDataSource ist etwas... nunja... komisch.
Ich habe es inzwischen auch geschafft, ein Feld einer Datenbank anzuzeigen (für alle Datensätze).
Delphi-Quellcode:
  aslSQLDB.DefaultExt := '';
  aslSQLDB.DefaultDir := ExtractFilePath(self.sDatabase);
  aslSQLDB.Database := 'MyDB';
  aslSQLDB.Connected := true;

  aslSQLTable.TableName := 'songTable';
  aslSQLTable.Open;

  aslSQLTable.Prior;
  while not aslSQLTable.Eof do begin
    ListBox1.Items.Add(aslSQLTable.FieldValues['cSongTitle']);
    aslSQLTable.Next;
  end;
Allerdings ist meine Frage jetzt, wie ich das, was ich bekommen habe mit einer SQL-Anweisung verknüpfen kann (SELECT-Anweisung) und das Ergebnis dieser Query immer noch innerhalb der While-Schleife verwenden kann?

Chris
  Mit Zitat antworten Zitat
CalganX

Registriert seit: 21. Jul 2002
Ort: Bonn
5.403 Beiträge
 
Turbo Delphi für Win32
 
#3

Re: Arbeiten mit SQLite

  Alt 15. Okt 2004, 13:58
Hi,
habe auch das jetzt nach einigen Stunden herumspielen geschafft.
Ich habe einfach ein TQuery-Nachfahre genommen und den verwendet. Genaue Beschreibung folgt zu Hause (stündchen; als Edit).

Chris
  Mit Zitat antworten Zitat
aducom

Registriert seit: 24. Okt 2004
Ort: groningen
4 Beiträge
 
#4

Re: Arbeiten mit SQLite

  Alt 24. Okt 2004, 09:46
Sorry, but being Dutch, I'm quite able to read, speak and listen to German, but writing is a different story.

The SQLite components with TDataSource work quite similar to the ones used with the BDE, although the BDE is NOT used. To use TAsqliteTable you need to set a filter to be able toselect on your dataset and next a locate can be used to search within the result set.

Why the prior statement? On open the first row is selected and presented. To search the first record you could apply .first().

Generally a basic application should look like this:

Put a TASQLiteDB componentn on your for, select the appropiate dll, the database main directory and database.
Put a TASQLiteTable component on your form and select the TASQLiteDB on the connection property. Select the wanted table.
Put a TDataSource on the form and connect to the TASQLiteTable
Put a DBGrid on the form and connect to the datasource.
Open the table.

Just as you would build a BDE application isn't it/

With the TASQLiteQuery you can apply your sql yourself.

Creating all the components on runtime, well this is possible (of course) but why not apply the components to the form?

If any questions left you can register through the support forum.

Delphi/C++ Freeware SQLite components

Albert Drent
aducom software support group.
  Mit Zitat antworten Zitat
CalganX

Registriert seit: 21. Jul 2002
Ort: Bonn
5.403 Beiträge
 
Turbo Delphi für Win32
 
#5

Re: Arbeiten mit SQLite

  Alt 24. Okt 2004, 12:24
Hi,
Zitat von aducom:
The SQLite components with TDataSource work quite similar to the ones used with the BDE, although the BDE is NOT used.
Well... this is maybe very easy for someone, who used BDE before, but I've never used it because the only thing I've done with databases was PHP and MySQL.

Zitat:
Why the prior statement? On open the first row is selected and presented. To search the first record you could apply .first().
Umm.. okay. As I've said: I've never worked with BDE. I just looked on a tutorial for firebase and there was .Prior in use.

Zitat:
Creating all the components on runtime, well this is possible (of course) but why not apply the components to the form?
The components themself are on my form. If you mean the properties: When I design my GUI I do not know where the database is. So I have to let the user select, on which drive the file should be.

Thanks for your help,
Chris
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:22 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz