Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi E2010 Incompatible types: 'string' and 'PAnsiChar' (https://www.delphipraxis.net/70551-e2010-incompatible-types-string-pansichar.html)

Mr.Goro 31. Mai 2006 19:54


E2010 Incompatible types: 'string' and 'PAnsiChar'
 
Ich habe verucht ein Programm mit MySQL-Abfrage zu schreiben, bin dabei aber auf ein Problem gestoßen:

Delphi-Quellcode:
 username := PChar(LoginName.Text);
 query := 'SELECT * FROM lgm_users WEHRE Username=' + username + '';
LoginName ist ein Edit-Feld! Usernam ist als PChar deklariert!
Ich erhalte aber folgende Fehlermeldung:

[Pascal Error] Unit1.pas(73): E2010 Incompatible types: 'string' and 'PAnsiChar'

Die sich auf die Zeile "query := ..." bezieht!
Könnt ihr mir helfen?

Hoffe mal das war das richtige Forum!

Sko 31. Mai 2006 19:57

Re: E2010 Incompatible types: 'string' and 'PAnsiChar'
 
So sollte es gehen:

Delphi-Quellcode:
username := PChar(LoginName.Text);
query := PAnsiChar('SELECT * FROM lgm_users WEHRE Username=' + username + '');
...wenn bei Datenbanken nicht irgendwas anders läuft, mit Datenbanken hab ich mich noch garnicht befasst.

Mr.Goro 31. Mai 2006 20:00

Re: E2010 Incompatible types: 'string' and 'PAnsiChar'
 
Danke funktioniert super!


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:10 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