首页 >数据库 >mysql教程 >delphi 连接MYSQL 的方法_MySQL

delphi 连接MYSQL 的方法_MySQL

WBOY
WBOY原创
2016-06-01 13:14:302400浏览

需要的控件:(view as form)

1、SQLConnection1: TSQLConnection
ConnectionName = 'MYSQLCONNECTION'
DriverName = 'MySQL'
GetDriverFunc = 'getSQLDriverMYSQL'
LibraryName = 'dbxmys.dll'
LoginPrompt = False
Params.Strings = (
'HostName=localhost'
'Database=mysqldb'
'User_Name=root'
'Password=pswd'
'MaxBlobSize=-1

ServerCharSet=utf8')
VendorLib = 'libmysql.dll'
Connected = True

2、 SQLTable1: TSQLTable
GetMetadata = False
MaxBlobSize = -1
SQLConnection = SQLConnection1
TableName = 'human'


3、DataSource1: TDataSource
DataSet = ClientDataSet1

4、DataSetProvider1: TDataSetProvider
DataSet = SQLTable1

5、ClientDataSet1: TClientDataSet
Active = True
ProviderName = 'DataSetProvider1'

6、DBGrid1: TDBGrid
DataSource = DataSource1

7、 DBNavigator1: TDBNavigator
 DataSource = DataSource1
 

8、Button1: TButton
Caption = 'Button1'
OnClick = Button1Click

 

代码:

procedure TForm1.Button1Click(Sender: TObject);
begin
  ClientDataSet1.ApplyUpdates(0);//更新
end;

最后找到两个库文件一同发布就可以了。

LibraryName = 'dbxmys.dll'
VendorLib = 'libmysql.dll'

 

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn