Use the DBExpress component of Delphi6 to connect to a remote Mysql database

Source: Internet
Author: User
Tags interbase
The new DBExpress in Delphi6 is used to deal with databases such as Mysql, DB2, Interbase, and Oracle. copy the dll to the current directory or system directory (98: system, NT: system32), and ensure that your port 3306 is consistent with the remote server. Source program: interfaceusesWindows, Messages, SysUtils

The new DBExpress in Delphi6 is used to deal with databases such as Mysql, DB2, Interbase, and Oracle. copy the dll to the current directory or system directory (98: system, NT: system32), and ensure that your port 3306 is consistent with the remote server. Source program: interface uses Windows, Messages, SysUtils

DBExpress added by Delphi6 is used to deal with Mysql, DB2, Interbase, Oracle and other databases.
Copy the file to the current directory or system directory (98: system, NT: system32), and ensure that your port 3306 is consistent with the remote server.
Source program:
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;
Performance1: 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.

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.