当前位置:七道奇文章资讯数据防范MySQL防范
日期:2011-05-02 15:44:00  来源:本站整理

利用Delphi6的DBExpress组件衔接远程的Mysql数据库[MySQL防范]

赞助商链接



  本文“利用Delphi6的DBExpress组件衔接远程的Mysql数据库[MySQL防范]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
Delphi6新增的DBExpress专门用来对付MySQL,DB2,Interbase,Oracle数据库,利用时注意将libmysql.dll

拷贝到当前目录或系统目录(98:system,NT:system32)下,并保证您的3306端口与远程服务器是相通的.

源程序:

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, DBXpress, DB, SqlExpr, StdCtrls, ComCtrls, FMTBcd, Grids,

DBGrids, Provider, DBClient, DBLocal, DBLocalS, DBTables;

type

TForm1 = class(TForm)

SQLConnection: TSQLConnection;

StatusBar1: TStatusBar;

Label1: TLabel;

DataSource1: TDataSource;

DBGrid1: TDBGrid;

GroupBox1: TGroupBox;

Label2: TLabel;

Password: TEdit;

User_Name: TEdit;

HostName: TEdit;

Label3: TLabel;

Label4: TLabel;

Button1: TButton;

GroupBox2: TGroupBox;

Label5: TLabel;

ESQL: TEdit;

Label6: TLabel;

Database: TEdit;

ButtonGo: TButton;

SQLClientDataSet: TSQLClientDataSet;

procedure Button1Click(Sender: TObject);

procedure ButtonGoClick(Sender: TObject);

procedure FormClose(Sender: TObject; var Action: TCloseAction);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

begin

with SQLConnection do

begin

Close;

Params.Values['HostName']:=HostName.Text;

Params.Values['UserName']:=User_Name.Text;

Params.Values['Password']:=Password.Text;

Params.Values['Database']:=Database.Text;

try

Connected:=True;

Statusbar1.Panels[0].Text:='Connect OK';

ButtonGo.Enabled:=True;

except

MessageDlg('Connect Error',mtError,[mbyes],0);

end;

end;

end;

procedure TForm1.ButtonGoClick(Sender: TObject);

begin

with SQLClientDataSet do

begin

Close;

CommandText:=ESQL.Text;

Open;

end;

end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);

begin

SQLConnection.Close;

end;

end.   以上是“利用Delphi6的DBExpress组件衔接远程的Mysql数据库[MySQL防范]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
  • 利用Delphi6的DBExpress组件衔接远程的Mysql数据库
  • 在C++Builder中利用Delphi文件
  • 在C++Builder中利用Delphi控件
  • 本文地址: 与您的QQ/BBS好友分享!
    • 好的评价 如果您觉得此文章好,就请您
        0%(0)
    • 差的评价 如果您觉得此文章差,就请您
        0%(0)

    文章评论评论内容只代表网友观点,与本站立场无关!

       评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
    Copyright © 2020-2022 www.xiamiku.com. All Rights Reserved .