(1)通过ODBC+ADO的方式连:
with ADOCon1 do
begin
Close;
ConnectionString:=( 'DRIVER={MySQL ODBC 5.1 Driver}; '+
'SERVER=192.168.1.107; '+
'DATABASE=test; '+
'USER=root; '+
'PASSWORD=root; '+
'PORT=3406; '+
'OPTION=3; ');
try
Open;
application.MessageBox( '连接成功!', '提示 ',MB_ICONINFORMATION);
except
application.MessageBox( '无法连接数据库服务器.请与管理员联系 ', '提示 ',MB_ICONINFORMATION);
end; //try
end; //with
(2)通过DBExpress连:
SQLConnection1.Connected:= false;
with SQLConnection1.Params do
begin
Text:='DriverName=MSSQL'+#13+
'ServerPort=' + 3406 + #13+<