How to connect to MYSQL using delphi

Source: Internet
Author: User

Required controls: (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. performance1: TDataSource
DataSet = ClientDataSet1

4. DataSetProvider1: TDataSetProvider
DataSet = SQLTable1

5. ClientDataSet1: TClientDataSet
Active = True
ProviderName = 'datasetprovider1'

6. DBGrid1: TDBGrid
DataSource = performance1

7. DBNavigator1: TDBNavigator
DataSource = performance1
 

8. Button1: TButton
Caption = 'button1'
OnClick = Button1Click

 

Code:

Procedure TForm1.Button1Click (Sender: TObject );
Begin
ClientDataSet1.ApplyUpdates (0); // update
End;

Finally, you can find the two library files and publish them together.

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.