Home  >  Article  >  Database  >  dbexpress 连接 mysql_MySQL

dbexpress 连接 mysql_MySQL

WBOY
WBOYOriginal
2016-06-01 13:11:301219browse

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 版本问题

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn