Delphi 2010和MySQL

有没有人知道设置和使用Delphi 2010与
MySQL的简单tuturial? 最佳答案 使用TAdoConnection和TAdoQuery:

implementation
uses adodb;
{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  mAdoConnection: TAdoConnection;
  mAdoQuery: TAdoQuery;
begin
  mAdoConnection := TAdoConnection.Create(application);
  mAdoConnection.ConnectionString := 'Mode=ReadWrite;Extended Properties="DRIVER=MySQL ODBC 3.51 Driver;DATABASE=mydatabase;SERVER=myserver;UID=myusername;PASSWORD=mypassword;PORT=;OPTION=3;STMT=;"';
  mAdoConnection.LoginPrompt := False;
  mAdoConnection.Open;
  mAdoQuery:=TADOQuery.Create(application);

  with mAdoQuery do begin
    Connection:=mADOConnection;
    CursorType := ctStatic;
    ParamCheck := False;
    SQL.Add('SELECT * FROM SYSSET');
  end;
  mAdoQuery.Open;
  showmessage(mAdoQuery.fields[0].AsString);
  mAdoQuery.free;
  mAdoConnection.Free;


end;

注意:将“我的…..”更改为您的服务器,数据库,用户名和密码.这还假设您在计算机上安装了MySql ODBC驱动程序.

点赞