当前位置:Gxlcms > mysql > dbexpress连接mysql_MySQL

dbexpress连接mysql_MySQL

时间:2021-07-01 10:21:17 帮助过:23人阅读

program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
System.SysUtils,data.DB, data.DBXCommon,classes, data.sqlexpr,vcl.dialogs,
Data.DBXMySQL;
var
fsqlconn:Tsqlconnection;
begin

try
{ TODO -oUser -cConsole Main : Insert code here }
fsqlconn:=TsqlConnection.Create(nil);

fsqlconn.ConnectionName:='MYSQLCONNECTION';
fsqlConn.DriverName:='MySQL';
fsqlConn.LoginPrompt:=false;
fsqlconn.Params.Clear;

fsqlConn.Params.Add('VendorLib=F:/soft/database/mysql/LIBMYSQL.dll');
fsqlconn.Params.Add('ServerCharSet=utf8');
fsqlconn.Params.Add('HostName=localhost');
fsqlconn.Params.Add('Database=lzf');
fsqlConn.Params.Add('User_Name=lzf');
fsqlConn.Params.Add('Password=123456');
fsqlconn.Params.Add('Compressed=False');
fsqlconn.Params.Add('Encrypted=False');

fsqlConn.Open;
showmessage('Good');
fsqlConn.Close;
except
on E: Exception do
begin
Writeln(E.ClassName, ': ', E.Message);
showmessage(e.Message);
fsqlconn.Free;
end;
end;

end.

xe2和xe5的唯一区别是:

fsqlconn.VendorLib:='F:/soft/database/mysql/libmysql.dll';

有点不好的是,好像还是只能支持5.1.63左右的libmysql.dll

也有人说 是 libmysql.dll 版本问题

人气教程排行