Einzelnen Beitrag anzeigen

Benutzerbild von geskill
geskill

Registriert seit: 17. Feb 2007
Ort: NRW
420 Beiträge
 
Delphi 2010 Professional
 
#4

AW: Zugriff auf MySQL ohne Komponenten mit Delphi XE2

  Alt 1. Okt 2011, 22:03
Sieht wie ein Unicode/Ansi Problem aus. TurboDelphi benutzt ja standardmäßig AnsiString.

Delphi-Quellcode:
procedure connect;
var Datei: TextFile;
      MyString: Ansistring;
begin
    AssignFile(Datei, ExtractFilePath(Application.ExeName) + 'SQL.set');
    Reset(Datei);
    try
      ReadLn(Datei, MyString);
      host := PAnsiChar(copy(MyString, pos(':', MyString)+1, length(MyString)));
      ReadLn(Datei, MyString);
      User := PAnsiChar(copy(MyString, pos(':', MyString)+1, length(MyString)));
      ReadLn(Datei, MyString);
      Pass := PAnsiChar(copy(MyString, pos(':', MyString)+1, length(MyString)));
      ReadLn(Datei, MyString);
      DB := PAnsiChar(copy(MyString, pos(':', MyString)+1, length(MyString)));
    finally
      CloseFile(Datei);
    end;

    //...

EDIT:
Quatsch der Fehler kommt ja schon vorher. Denke mal du hast dann die neue mysql.pas (Version 2011-09-15)
für XE2. Im Header steht da folgendes:

Zitat:
procedure mysql_server_end;
{ "Jeremiah Gowdy" <jgowdycox.net> wrote on 10/11/2005 03:08:40 AM:
The Windows DLL is thread safe. You do not have to call my_init()
and my_thread_init() because Windows DLLs receive events when they
are attached to a new process and when they are attached to a new
thread in a process. This is one of the nicer features of Windows
shared libraries. Other than that, you don't have to do anything
special. I am a heavy user of libmysql under Win32. You simply
mysql_init() your MYSQL struct, and then mysql_real_connect() and
you're ready to mysql_query().
New on February 17, 2009 02:27AM: This is true until 5.0.77 -
since this version this nice feature ist removed from dll.c.
To obtain the previous behavior (DLL initialization code will be
called), set the LIBMYSQL_DLLINIT environment variable to
any value. http://forums.mysql.com/read.php?3,248207,248207 }
function mysql_thread_init: my_bool; //called internal by mysql_init or mysql_server_init
{ New on February 17, 2009 02:27AM: Since 5.0.77 mysql_thread_end
is not called during DllMain() if the LIBMYSQL_DLLINIT environment variable is
not set. So it is necessary to call mysql_thread_end to avoid memory leaks. }
procedure mysql_thread_end;
Aber das wäre ja nur der Fall für Threadsicherheit.

Aber du hast ja nicht die Unit von TurboDelphi für XE2 benutzt, weil da brauchst du denke ich
die neue welche extra dafür kompatibel gemacht wurde.
Sebastian

Geändert von geskill ( 1. Okt 2011 um 22:18 Uhr)
  Mit Zitat antworten Zitat