delphi连接mysql数据库

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DBXpress, SqlExpr, DB, ADODB, Grids, DBGrids;

type
  TForm1 = class(TForm)
    ADOConnection1: TADOConnection;
    SQLConnection1: TSQLConnection;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    ADOQuery1: TADOQuery;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  ADOConnection1.ConnectionString:=('DRIVER={MySQL ODBC 3.51 Driver};'+
                  'SERVER=localhost;'+        //服务器
                  'DATABASE=xeeder;'+         //MYSQL 上的数据库
                  'USER=root;'+               //用户名
                  'PASSWORD=12345;'+          //密码
                  'OPTION=3;');
   ADOConnection1.Close;
   ADOConnection1.Open;
end;

end.

你可能感兴趣的:(delphi连接mysql数据库)