Home > Back-end >  DELPHI XE with zeosdbo connection MYSQL for field shows the code
DELPHI XE with zeosdbo connection MYSQL for field shows the code

Time:11-13

DELPHI XE10.2 with zeosdbo 7.2.4 - stable connection MYSQL database, access to field shows the code, the following is a code, you can think of transformation ways are tried, is that no one can show Chinese normally, the following is the database Settings, records, according to the code format and the original code, a masters help you:





Zqry1. Close;
Zqry1. SQL. Text:='set names UTF8;
Zqry1. ExecSQL;

Zqry1. SQL. Text:='SELECT * FROM info_player1';
Zqry1. Open;

ShowMessage (UTF8Encode (zqry1 FieldByName (' IP '). AsString) are identical);
ShowMessage (UTF8Decode (zqry1 FieldByName (' IP '). AsString) are identical);
ShowMessage (Utf8ToAnsi (zqry1 FieldByName (' IP '). AsString) are identical);
ShowMessage (UTF8ToString (zqry1 FieldByName (' IP '). AsString) are identical);
ShowMessage (UTF8ToWideString (zqry1 FieldByName (' IP '). AsString) are identical);
ShowMessage (UTF8ToUnicodeString (zqry1 FieldByName (' IP '). AsString) are identical);
ShowMessage (UTF8EncodeToShortString (zqry1 FieldByName (' IP '). AsString) are identical);

ShowMessage (UTF8Encode (zqry1 FieldByName (' IP '). AsWideString));
ShowMessage (UTF8Decode (zqry1 FieldByName (' IP '). AsWideString));
ShowMessage (Utf8ToAnsi (zqry1 FieldByName (' IP '). AsWideString));
ShowMessage (UTF8ToString (zqry1 FieldByName (' IP '). AsWideString));
ShowMessage (UTF8ToWideString (zqry1 FieldByName (' IP '). AsWideString));
ShowMessage (UTF8ToUnicodeString (zqry1 FieldByName (' IP '). AsWideString));
ShowMessage (UTF8EncodeToShortString (zqry1 FieldByName (' IP '). AsWideString));

ShowMessage (UTF8Encode (zqry1 FieldByName (' IP '). AsAnsiString));
ShowMessage (UTF8Decode (zqry1 FieldByName (' IP '). AsAnsiString));
ShowMessage (Utf8ToAnsi (zqry1 FieldByName (' IP '). AsAnsiString));
ShowMessage (UTF8ToString (zqry1 FieldByName (' IP '). AsAnsiString));
ShowMessage (UTF8ToWideString (zqry1 FieldByName (' IP '). AsAnsiString));
ShowMessage (UTF8ToUnicodeString (zqry1 FieldByName (' IP '). AsAnsiString));
ShowMessage (UTF8EncodeToShortString (zqry1 FieldByName (' IP '). AsAnsiString));

Zqry1. Close;

Ps: in DELPHI7 zqry1. SQL. Text:='set GBK names, then ShowMessage (zqry1. FieldByName (' IP'). AsString) are identical. There is no garbled XE10 just to fit in completely don't adapt to,

CodePudding user response:

TZConnection zqry1 you should have a TZConnection, this should be a ClientCodepage properties, and there should be a utf8 ClientCodepage

CodePudding user response:

Words, since the XE10.2, why don't FireDAC?

CodePudding user response:

UTF8Encode (zqry1 FieldByName (' IP '). AsAnsiString)


There are UTF8 encoding AnsiString?

The String is UTF8 encoding!

AsAnsiString AsString instead try next

CodePudding user response:

This should be adjusted on link, do not need to set names or UTF8Decode,
Try adjusting the Connection properties, ClientCodepage:='utf8' and AutoEncodeStrings:=true

CodePudding user response:

Delphi has UTF8String high version, can:
Var
S: UTF8String;
//...
S:=zqry1 FieldByName (' IP '). The Value;

CodePudding user response:

With TFDConnection, still can use the connection pool, use the
 
The unit fmDataModule;

Interface

USES the
Winapi. Windows, Winapi Messages, System. SysUtils, System. Variants, System. Classes,
The Vcl. Graphics, Vcl. Controls, Vcl. Forms, Vcl. Dialogs, Vcl. StdCtrls, Vcl. ExtCtrls,
MidasLib, System. SyncObjs, FireDAC. Stan. Intf, FireDAC. Stan. Option, FireDAC. Stan. The ERROR,
FireDAC. UI. Intf, FireDAC. Stan. Def, FireDAC. Stan. Pool, duTypes, FireDAC. Stan. Async,
Data. DBXCommon FireDAC. J Phys, FireDAC. VCLUI. Wait, and Data. The DB, FireDAC.Com p.C lient,
Data. SqlExpr Data. DBXMySQL Data. DBXMSSQL, Data. FMTBcd, Datasnap. DBClient,
Datasnap Provider, FireDAC. Phys., MSSQLDef FireDAC. Phys., ODBCBase FireDAC. Phys., MSSQL,
FireDAC. Phys. Intf, FireDAC. ConsoleUI. Wait, FireDAC. Stan. Param, FireDAC. DatS,
FireDAC. DApt. Intf, FireDAC DApt, FireDAC. Phys., MySQLDef FireDAC. Phys., MySQL,
FireDAC.Com conviction yourself ataSet;

Type
TLockMySQLDataModule=class (TDataModule)
FDPhysMySQLDriverLink1: TFDPhysMySQLDriverLink;
FDManager1: TFDManager;
Procedure DataModuleCreate (Sender: TObject);
Procedure DataModuleDestroy (Sender: TObject);
Private
OParams: TStringList;
Protected

{Private declarations}
Public
The function GetDate (ASql: string; AClientDataSet: the TClientDataSet; Var AErrStr: string) : Boolean;
The function ExecSQL (ASql: string; Var AErrStr: string) : Boolean;
The function ExecSqlList (ASqlList: TStrings; Var AErrStr: string) : Boolean;
The function DBConnectedTest (var AErrStr: string) : Boolean;
Procedure WriteHttpLog (Aurl, AContent ARemoteIP, AErrMsg: string).
Procedure WriteTCPLog (Aurl, AContent ARemoteIP, AErrMsg: string).

end;

Var
G_DataModule: TLockMySQLDataModule;

Implementation


{% CLASSGROUP 'System. Classes. TPersistent'}

{$R *. DFM}

USES the
DuGlob duTConfigClass;


nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related