第二种方法:mysql.pas到这里下载:http://www.shijiku.com/data/libmysql.pashttp://www.shijiku.com/data/libmysql5.dll或者自己去baidu,google。连接代码例子:procedure TForm1.BitBtn1Click(Sender: TObject);var dbh : PMYSQL; MResult : PMYSQL_RES; Row : PMYSQL_ROW; rowc : my_ulonglong; lint : longint;begin //libmysql_load(PChar('libmysql.dll')); libmysql_load(nil); dbh:=mysql_init(nil); if dbh=nil then begin Memo1.Lines.Add('初始化错误'); exit; end; Memo1.Lines.Add('libmysql_status='+#9+IntToStr(libmysql_status)); Memo1.Lines.Add('libmysql_handle='+#9+IntToStr(libmysql_handle)); //if nil=mysql_real_connect(dbh, PChar('localhost'), PChar('root'), Pchar(''), PChar(''), 3306, nil, 0) then begin if nil=mysql_connect(dbh, PChar('localhost:3306'), PChar('root'), Pchar('')) then begin Memo1.Lines.Add('无法连接数据库服务器:'+#13#10+mysql_error(dbh)); exit; end; Memo1.Lines.Add('mysql_get_client_info='+#9+mysql_get_client_info); Memo1.Lines.Add('mysql_get_host_info='+#9+mysql_get_host_info(dbh)); Memo1.Lines.Add('mysql_get_server_info='+#9+mysql_get_server_info(dbh)); mysql_query(dbh, PChar('SHOW VARIABLES')); MResult:=mysql_use_result(dbh); rowc:=mysql_num_rows(MResult); Memo1.Lines.Add('Rowc='+#9+IntToStr(rowc)); Row:=mysql_fetch_row(MResult); while Row<>nil do begin Memo1.Lines.Add(Row[0] + #9#9+Row[1]); Row:=mysql_fetch_row(MResult); end; //mysql_query(dbh, PChar('LOAD DATA LOCAL INFILE "E://mapfile.txt" ' // +'INTO TABLE a_logs1 FIELDS TERMINATED BY ";" ENCLOSED BY ''"'' ESCAPED BY "//" LINES TERMINATED BY "/r/n"')); Memo1.Lines.Add('mysql_error='+#9+mysql_error(dbh)); lint:=mysql_ping(dbh); Memo1.Lines.Add('mysql_ping='+#9+IntToStr(lint)); Memo1.Lines.Add('mysql_ping='+#9+IntToStr(lint));end;从SQL2000取出数据构造成insert into语句,只需要执行 mysql_query(dbh, PChar(构造的insert语句));var sql : string; k : integer;begin sql:=''; k:=1;with ADOQuery_Source dobegin First; while not eof do begin sql:=sql+',("'+FieldByName('test').asString;+'")'; inc(k); if k>1000 then begin sql[1]:=#32; mysql_query(dbh, PChar('insert into tablename (FieldName)values'+sql)); k:=1; sql:=''; end; end;end;