Autor Beitrag
Chris Maslowski
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 109



BeitragVerfasst: Do 05.01.06 17:49 
Hallo,
ich möchte mit einem Delphi Programm auf eine MySQL Datenbank zugreifen. Ich wollte mir dafür eigentlich keine neue Version kaufen :D
Also will ich das mit Delpi 3 machen. Dazu braucht man ja neue Klassen. Ich hab es mal mit zeosdbo versucht. Aber da hab ich nicht ganz durchgeblickt. Dann hab ich es mit Mysql-direct library probiert. Ich glaube da hab ich es sogar richtig gemacht :D Da waren 9 Units und die hab ich alle in mein aktuelles Projekt eingebunden. Doch der Compiler zeigt mir eine Menge Fehlermeldungen wie:
; oder ) anstelle von = erwartet
Diese Meldung hat der ziemlich oft ausgespuckt. Bei fast jeder Unit.

Jetzt meine Frage. Wie kann ich am besten mit mysql und delphi anfangen???
Chris Maslowski Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 109



BeitragVerfasst: Do 05.01.06 23:58 
Naja ein paar mehr Antworten hätte ich mir schon erhofft. Vielleicht hilft euch der Code:
ausblenden Delphi-Quelltext
1:
function vio_open( _type:TEnumVioType; host:string='localhost'; unix_socket:string={$IFDEF _WIN_}MYSQL_NAMEDPIPE{$ELSE}MYSQL_UNIX_ADDR{$ENDIF}; port:longint=0; connect_timeout:cardinal=0; trysock:boolean=true):longint;					

Bei dem markierten Teil sagt der Compiler mir, dass er ein ; oder ) erwartet aber kein;

Moderiert von user profile iconUGrohne: Unterstreichung durch Highlighting ersetzt.
fränk0815
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 22

Windows XP Prof. SP2
Delphi 2006 Prof. (Win32)
BeitragVerfasst: Fr 06.01.06 10:13 
Hallo,

welche Version von MySqlDirect verwendest du ?

Normalerweise reicht es aus die Unit uMySqlClient in das Projekt einzubinden.

Dann machst du folgendes:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
procedure TForm1.Button1Click(Sender: TObject);
var
  Client: TMySqlClient;
  FResult: TMySqlResult;
  Ex : Boolean;
  q : String;
begin
  Client := TMySqlClient.Create;
  Client.Host := 'localhost';
  // hier die übrigen Zugangsdaten und Parameter;

  if Client.connect then
  begin
    q := 'dein sql-statement';
    FResult := Client.query(q,false,ex);
    if Fresult then
    begin
      //mach was mit dem Ergebniss
    end;
  end;
  Client.Close;
  FreeAndNil(Client);
end;



... versuchs mal so, ansonsten frag nochmal :)

LG
Frank
Chris Maslowski Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 109



BeitragVerfasst: Fr 06.01.06 11:25 
Titel: ..
Ich verwende Version 1.2.2!!
Ich würde das ja gerne einbinden, aber daran scheitert das ja schon. Ich glaub die Units sind fehlerhaft, der Compiler hat da ja was zu mecker. Ich probiers erst mal mit einer anderen Version.
Danke für die Hilfe.
fränk0815
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 22

Windows XP Prof. SP2
Delphi 2006 Prof. (Win32)
BeitragVerfasst: Fr 06.01.06 11:31 
Die Units sind definitiv nicht Fehlerhaft, ich verwende die ja auch sehr erfolgreich in mehreren Projekten.

Eventuell magst mal die von dir verwendeten Units anhängen ? Dann könnte man die mal anschauen :)

LG
Frank
Chris Maslowski Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 109



BeitragVerfasst: Fr 06.01.06 11:36 
Titel: Die Units
Ok DAnke das du dir die angucken willst. Hab sie beigehängt :D
Einloggen, um Attachments anzusehen!
fränk0815
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 22

Windows XP Prof. SP2
Delphi 2006 Prof. (Win32)
BeitragVerfasst: Fr 06.01.06 11:49 
Also in D6, 7 und 2006 funktioniert das alles einwandfrei.

Könnte eventuell an D3 liegen ? Kann ich aber nicht testen, da ich keines habe / nie hatte :)


Tut mir leid dir nicht weiterhelfen zu können.
Chris Maslowski Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 109



BeitragVerfasst: Fr 06.01.06 11:58 
Ja das könnte sein. Vielleicht liegt das auch daran das ich was falsch im Quelltext eingefügt habe. Im Tutorial stand man solle das direkt nach den uses einfügen:
ausblenden Delphi-Quelltext
1:
{$I mysqlinc.inc}					

Da standen auch noch andere Anweisungen, so das mein Quelltext so aussieht:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  umysqlvio, uMysqlCT, uMysqlClient, uMysqlHelpers;
  {$I mysqlinc.inc}

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private-Deklarationen }
  FMysql: TMysqlClient;
  FResult: TMysqlResult;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  FMysql := TMysqlClient.create;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  FMysql.Free;
  if FResult<>nil then
    FResult.free;
end;

end.
fränk0815
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 22

Windows XP Prof. SP2
Delphi 2006 Prof. (Win32)
BeitragVerfasst: Fr 06.01.06 12:18 
Tu mal unter Uses nur die uMysqlClient Datei rein und lass die *.inc Datei mal weg. Könnte helfen.
Chris Maslowski Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 109



BeitragVerfasst: Fr 06.01.06 12:23 
Schade ich bekomm immer noch den selben Fehler. Ich glaub ich hab eine Heft CD wo Delphi 2005 drauf ist und irgendwo Delphi 7 PE. Ich probiers damit mal(Wenn ich die CD gefunden hab). Danke für eure Hilfe, liegt wohl an Delphi 3 (Obwohl das die Proffesionall Version ist)
Chris Maslowski Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 109



BeitragVerfasst: Fr 06.01.06 13:28 
MIt Delphi 7 klappt's.!!!!!
Juhuuu
DAnke für die Hilfe.