![]() |
MySQL Fehler
hi, kann mir jemand diesen fehler erklären:
![]() ? Ich sende folgendes:
Delphi-Quellcode:
ich wunder mich auch wieso es in der fehlermeldung nur buis "CREATE TABL" geht... ich hab doch mehr gesendet?
procedure TForm2.Button2Click(Sender: TObject);
begin Form1.c.HostName := Edit1.Text; Form1.c.Port := StrToInt(Edit2.Text); Form1.c.User := Edit3.Text; Form1.c.Password := Edit4.Text; Form1.q2.SQL.Clear; Form1.q2.SQL.Add('CREATE DATABASE ' + Edit7.Text + ';'); Form1.q2.SQL.Add('USE ' + Edit7.Text + ';'); Form1.q2.SQL.Add('CREATE TABLE ' + Edit5.Text + ';'); Form1.q2.SQL.Add('CREATE TABLE ' + Edit6.Text + ';'); Form1.q2.SQL.Add('CREATE TABLE ' + Edit7.Text + ';'); Form1.q2.ExecSQL; end; |
Re: MySQL Fehler
Zitat:
Zum Problem: Hast du die Abfrage schonmal ausgebenlassen, statt sie zu senden? |
Re: MySQL Fehler
moin,
was meinst du mit ausgeben lassen? |
Re: MySQL Fehler
Zitat:
oder so :) mfG mirage228 |
Re: MySQL Fehler
Ähm, du solltest vielleicht auch angeben wie die Tabellen aussehen sollen die du mit CREATE TABLE erstellen willst????
|
Re: MySQL Fehler
Was du machen willst ist ein ganzes Skript an den Server schicken. Das klappt abe so nicht über Delphi. Stattdessen solltest du versuchen jede Anweisung einzeln an den Server zu schicken.
|
Re: MySQL Fehler
Zitat:
Ich habe eine kleine Funktion geschrieben, die z. B. einen MySQL-Dump auseinandernimmt und die einzelnen Queries in einen Array schreibt:
Delphi-Quellcode:
Da ich noch ein relativer Anfänger in Delphi bin, hoffe ich, keine schweren Fehler in die Funktion eingebaut zu haben ...
// im Bereich interface :
// type // TSingleSQL = array of AnsiString; function DumpToSingleSQL(dump: AnsiString): TSingleSQL; var sql: AnsiString; inString, currChar: Char; inComment, ignore: Boolean; numberSingleSQL, dumpLen, i: Integer; ergebnis: TSingleSQL; begin // init vars: sql := ''; inString := #0; inComment := false; ignore := false; numberSingleSQL := 0; dump := trim(dump); dumpLen := Length(dump); for i := 1 to dumpLen do begin currChar := Copy(dump, i, 1)[1]; // if you are inside a comment if inComment then begin // do nothing until end of line if (currChar = #10) or (currChar = #13) then inComment := false; // but continue anyway Continue; end; // a comment begins with # -> do nothing if (currChar = '#') and (inString = #0) then begin inComment := true; Continue; end; // handle ignore if ignore then ignore := false else // ignore character after backslash (\) if currChar = '\' then ignore := true else // a string begins ... if ((currChar = '''') or (currChar = '"')) and (inString = #0) then inString := currChar else // a string ends ... if (currChar = inString) and (inString <> #0) then inString := #0 else // a query ends with ';' (which is not inside a string) if (currChar = ';') and (inString = #0) then begin sql := trim(sql); if sql <> '' then begin SetLength(Result, numberSingleSQL + 1); Result[numberSingleSQL] := sql; Inc(numberSingleSQL); sql := ''; end; Continue; end; sql := sql + currChar; end; // if last query does not end with ';' it should not matter: sql := trim(sql); if sql <> '' then begin SetLength(Result, numberSingleSQL + 1); Result[numberSingleSQL] := sql; end; end; Mamphil |
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:49 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz