Heim >Datenbank >MySQL-Tutorial >dbexpress 连接 mysql_MySQL
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的唯一区别是:
<pre class="prettyprint"><p>fsqlconn.VendorLib:='F:/soft/database/mysql/libmysql.dll'; </p>
有点不好的是,好像还是只能支持5.1.63左右的libmysql.dll
也有人说 是 libmysql.dll 版本问题