delphi中连接mysql数据库,数据源要怎么建
1个回答
展开全部
参考使用MysqlDac控件,有破解版下载。就想用ado连接sqlserver一样,不需建立数据源之类的。
Connection: TmySQLDatabase; //连接
Connection := TmySQLDatabase.Create(nil);
Connection.DatabaseName := DBName;
Connection.Host := DBAdrr;
Connection.UserName := UserName;
Connection.UserPassword := PassWord;
Connection.LoginPrompt := False;
if Connection.Connected = True then
Connection.Connected := False;
try
Connection.Open;
except
Result := False;
SetISConnected(False);
fLogIni.WriteString(DateTimeToStr(Now),'CONDATABASEERR','FALSE');
Exit;
end;
pQuery := TmySQLQuery.Create(nil);
pQuery.Database := fServerDB.Connection;
pQuery.SQL.Text :=
pQuery.Open;
while not pQuery.Eof do
begin
pQuery.FieldByName
。。。。。。。
Connection: TmySQLDatabase; //连接
Connection := TmySQLDatabase.Create(nil);
Connection.DatabaseName := DBName;
Connection.Host := DBAdrr;
Connection.UserName := UserName;
Connection.UserPassword := PassWord;
Connection.LoginPrompt := False;
if Connection.Connected = True then
Connection.Connected := False;
try
Connection.Open;
except
Result := False;
SetISConnected(False);
fLogIni.WriteString(DateTimeToStr(Now),'CONDATABASEERR','FALSE');
Exit;
end;
pQuery := TmySQLQuery.Create(nil);
pQuery.Database := fServerDB.Connection;
pQuery.SQL.Text :=
pQuery.Open;
while not pQuery.Eof do
begin
pQuery.FieldByName
。。。。。。。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询