欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

Delphi

當(dāng)前位置:主頁 > 軟件編程 > Delphi >

delphi7連接mysql5的實現(xiàn)方法

來源:本站原創(chuàng)|時間:2020-01-10|欄目:Delphi|點擊: 次

本文簡單介紹了Delphi7連接MySQL數(shù)據(jù)庫的實現(xiàn)方法,具體步驟如下:

首先先去下載:http://www.justsoftwaresolutions.co.uk/delphi/dbexpress_and_mysql_5.html

然后將下載到的dbxopenmysql5_dll.zip解壓出來,再把dbxopenmysql50.dll和libmysql.dll都放到工程文件夾下。

在Form上放上TSQLConnection、TSQLQuery、TStringGrid、3個TButton、TLable。

添加如下代碼:

unit Unit1;
interface
uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, DBXpress, FMTBcd, StdCtrls, Grids, DB, SqlExpr;
type
 TForm1 = class(TForm)
  SQLConnection1: TSQLConnection;
  SQLQuery1: TSQLQuery;
  StringGrid1: TStringGrid;
  Button1: TButton;
  Button2: TButton;
  Button3: TButton;
  Label1: TLabel;
  procedure Button1Click(Sender: TObject);
  procedure Button2Click(Sender: TObject);
  procedure Button3Click(Sender: TObject);
 private
  { Private declarations }
 public
  { Public declarations }
 end;
 
var
 Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.Button1Click(Sender: TObject);
begin
 SQLConnection1 := TSQLConnection.Create(nil);
 SQLConnection1.DriverName := 'dbxmysql';
 SQLConnection1.GetDriverFunc := 'getSQLDriverMYSQL50';
 SQLConnection1.LibraryName := 'dbxopenmysql50.dll';
 SQLConnection1.VendorLib := 'libmysql.dll';
 SQLConnection1.LoginPrompt := false;
 SQLConnection1.Params.Append('Database=mysql');
 SQLConnection1.Params.Append('User_Name=root');
 SQLConnection1.Params.Append('Password=');
 SQLConnection1.Params.Append('HostName=localhost');
 SQLConnection1.Open;
 if SQLConnection1.Connected = true then
 begin
  SQLQuery1.SQLConnection := SQLConnection1;
  Label1.Caption := 'success!';
 end
 else
  Label1.Caption := 'failed!';
end;
 
procedure TForm1.Button2Click(Sender: TObject);
var
 i, j: Integer;
begin 
 SQLQuery1.SQL.Clear;
 SQLQuery1.SQL.Add('SELECT * FROM user');
 SQLQuery1.Active := true;
 i := 0;
 SQLQuery1.First;
 while not SQLQuery1.eof do
 begin
  for j := 0 to SQLQuery1.FieldCount - 1 do
   StringGrid1.cells[j, i] := SQLQuery1.Fields[j].AsString;
  SQLQuery1.next;
  inc(i);
 end;
 SQLQuery1.Active := false;
end;
 
procedure TForm1.Button3Click(Sender: TObject);
begin
 if SQLConnection1.Connected = true then
  SQLConnection1.Close;
 SQLConnection1.Free;
end;
 
end.
  

經(jīng)測試,可實現(xiàn)正常連接與查詢。

上一篇:Delphi創(chuàng)建開機啟動項的方法示例

欄    目:Delphi

下一篇:Delphi實現(xiàn)檢測并枚舉系統(tǒng)安裝的打印機的方法

本文標(biāo)題:delphi7連接mysql5的實現(xiàn)方法

本文地址:http://mengdiqiu.com.cn/a1/Delphi/8622.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有