Here is an easy function to connect Mysql using TADOConnection.
You can put this function on the data module and then call it in main form.
function OpenConnection(host,database,username,password:string):boolean;
begin
try
ADOConnection1.Close;
ADOConnection1.ConnectionString := 'DRIVER={MySQL ODBC 3.51 Driver}; '+
'SERVER='+host+';'+
'DATABASE='+database+';' +
'UID='+username+';' +
'PASSWORD='+password+';' +
'OPTION=3;';
ADOConnection1.Open;
result:=true;
except
result:=false;
end;
end;
Happy coding ;)
0 comments:
Posting Komentar