mysqlfront软件,到我的站点下载。
www.chinesehis.com/soft/mysqlfront.zip
或者
先概述一下使用方法,
1,将ACCESS的数据库建立一个"system DSN";
2,根据ACCESS数据库中各表的名称,在MySQL中建立相应的各个空表;
3,运行fdlist.php;
4,运行import.php;
5,每运行一次3,4步可迁移一个表,然后修改fdlist.php中的ACCESS源表名和MySQL中的目标表名,再运行3,4步,直至迁移所有的表, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
以下为 fdlist.php源程序
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<html>
<head>
<style type=text/css>
body,td,li,div,p,pre,a,b,h1,h2,h3,h4 {font-family:verdana;font-size:9pt;line-height : 18px;color:#a00000 }
</style>
</head>
<? $dbconnection = @mysql_connect("yourmysqlserver", "mysqlaccount", "mysqlpassword") or die ("can not connect to database server"); @mysql_select_db("yourdatabase") or die("<p style='font-size:9pt;font-family:verdana;color:#803333;font-weight:bold'>No Database,</p>") ; $odbc_table = "youroriginaltable" ; // The original table name in your ODBC database $mysql_table = "yournewtable" ; // The new table name in your Mysql Database. ?> <body bgcolor=#f0f0f0 topmargin=0 leftmargin=0 text=#a00000> <br>
<div style="font-size:24pt;font-family:times;font-weight:bold;color:#00a000">Fields List of Two tables</div>
<hr size=1 color=#900000> <? $conn = odbc_connect("task", "", ""); $odbc_query = "select * from " . $odbc_table . " where 1=2"; $recordsid = odbc_exec($conn, $odbc_query); $idcounts = odbc_num_fields( $recordsid ) ; $fdlist1 = "" ; for ( $i = 1 ; $i <= $idcounts ; $i ++) $fdlist1 .= odbc_field_name($recordsid,$i)."," ; echo "<div> Fd1 = " . $fdlist1 ; $fdlist1 = substr($fdlist1,0,strlen($fdlist1)-1) ; $fdlist2 = "" ;
$sqlquery = "select * from " . $mysql_table . " where 1=2 " ; $records2 = mysql_query ($sqlquery) ; $idcount2 = mysql_num_fields ( $records2 ) ; for ( $i = 0 ; $i < $idcount2 ; $i++) $fdlist2 .= mysql_field_name($records2,$i )."," ; echo "<div> FD2 = " . $fdlist2 ; $fdlist2 = substr($fdlist2,0,strlen($fdlist2)-1) ; $fp = fopen ("fdlist.txt","w") ; fwrite ($fp,$ctable) ; fwrite ($fp,"n"); fwrite ($fp,$fdlist1) ; fwrite ($fp,"n"); fwrite ($fp,$etable) ; fwrite ($fp,"n") ; fwrite ($fp,$fdlist2) ; fclose($fp) ; odbc_close($conn); if ( $idcount2 != $idcounts ) { echo "<hr size=1 color=#900000>". "<div style='font-size:20pt;font-family:times;font-weight:bold'> The fields of two tables doesn't match" ; echo "<br><br>ODBC_table Fields = " . $idcounts; echo "<br><br>MySQL_table Fields = " . $idcount2;
}
?>
</body>
</html> ~~~~~~~~~~~~~~~~~~~
未完接(二)
www.chinesehis.com/soft/mysqlfront.zip
或者
先概述一下使用方法,
1,将ACCESS的数据库建立一个"system DSN";
2,根据ACCESS数据库中各表的名称,在MySQL中建立相应的各个空表;
3,运行fdlist.php;
4,运行import.php;
5,每运行一次3,4步可迁移一个表,然后修改fdlist.php中的ACCESS源表名和MySQL中的目标表名,再运行3,4步,直至迁移所有的表, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
以下为 fdlist.php源程序
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<html>
<head>
<style type=text/css>
body,td,li,div,p,pre,a,b,h1,h2,h3,h4 {font-family:verdana;font-size:9pt;line-height : 18px;color:#a00000 }
</style>
</head>
<? $dbconnection = @mysql_connect("yourmysqlserver", "mysqlaccount", "mysqlpassword") or die ("can not connect to database server"); @mysql_select_db("yourdatabase") or die("<p style='font-size:9pt;font-family:verdana;color:#803333;font-weight:bold'>No Database,</p>") ; $odbc_table = "youroriginaltable" ; // The original table name in your ODBC database $mysql_table = "yournewtable" ; // The new table name in your Mysql Database. ?> <body bgcolor=#f0f0f0 topmargin=0 leftmargin=0 text=#a00000> <br>
<div style="font-size:24pt;font-family:times;font-weight:bold;color:#00a000">Fields List of Two tables</div>
<hr size=1 color=#900000> <? $conn = odbc_connect("task", "", ""); $odbc_query = "select * from " . $odbc_table . " where 1=2"; $recordsid = odbc_exec($conn, $odbc_query); $idcounts = odbc_num_fields( $recordsid ) ; $fdlist1 = "" ; for ( $i = 1 ; $i <= $idcounts ; $i ++) $fdlist1 .= odbc_field_name($recordsid,$i)."," ; echo "<div> Fd1 = " . $fdlist1 ; $fdlist1 = substr($fdlist1,0,strlen($fdlist1)-1) ; $fdlist2 = "" ;
$sqlquery = "select * from " . $mysql_table . " where 1=2 " ; $records2 = mysql_query ($sqlquery) ; $idcount2 = mysql_num_fields ( $records2 ) ; for ( $i = 0 ; $i < $idcount2 ; $i++) $fdlist2 .= mysql_field_name($records2,$i )."," ; echo "<div> FD2 = " . $fdlist2 ; $fdlist2 = substr($fdlist2,0,strlen($fdlist2)-1) ; $fp = fopen ("fdlist.txt","w") ; fwrite ($fp,$ctable) ; fwrite ($fp,"n"); fwrite ($fp,$fdlist1) ; fwrite ($fp,"n"); fwrite ($fp,$etable) ; fwrite ($fp,"n") ; fwrite ($fp,$fdlist2) ; fclose($fp) ; odbc_close($conn); if ( $idcount2 != $idcounts ) { echo "<hr size=1 color=#900000>". "<div style='font-size:20pt;font-family:times;font-weight:bold'> The fields of two tables doesn't match" ; echo "<br><br>ODBC_table Fields = " . $idcounts; echo "<br><br>MySQL_table Fields = " . $idcount2;
}
?>
</body>
</html> ~~~~~~~~~~~~~~~~~~~
未完接(二)
以下为 import.php 源程序
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <html>
<head>
<style type=text/css>
body,td,li,div,p,pre,a,b,h1,h2,h3,h4 {font-family:verdana;font-size:9pt;line-height : 18px;color:#a00000 }
</style>
</head>
<body bgcolor=#f0f0f0 topmargin=0 leftmargin=0 text=#a00000>
<center>
<br>
<div style="font-size:24pt;font-family:times;font-weight:bold;color:#008000">ODBC --> MySQL Migrant</div> <hr size=1 color=#900000> <? $dbconnection = @mysql_connect("yourmysqlserver", "mysqlaccount", "mysqlpassword") or die ("can not connect to database server"); @mysql_select_db("yourdatabase") or die("<p style='font-size:9pt;font-family:verdana;color:#803333;font-weight:bold'>No Database,</p>") ;
$conn = odbc_connect("task", "", ""); $fp = fopen ("fdlist.txt","r") ; $table1 = fgets($fp,200); $fd1 = fgets($fp,1024) ; $table2 = fgets($fp,200); $fd2 = fgets($fp,1024) ;
$query1 = "select " . $fd1 . " from " . $table1 ; $query2 = "select " . $fd2 . " from " . $table2 . " where 1=2 " ; $result = mysql_query ($query2) ; mysql_query ("delete from " .$table2 ) ; echo "sql=". $query1; $recordsid = odbc_exec($conn, $query1); $idcounts = odbc_num_fields( $recordsid ) ; $idcount2 = mysql_num_fields($result) ; if ( $idcounts != $idcount2 )
die (" The fields of two tables doesn't match ") ; echo "<table width=90% border=1 bordercolorlight=#000000 bordercolordark=#ffffff cellpadding=3 cellspacing=0>n" ; echo "<tr align=center><td> n " ; for ( $i = 1 ; $i <= $idcounts ; $i ++) echo "n<td>" . odbc_field_name($recordsid,$i) ; $theno = 1 ; echo "<tr>n" ; while (odbc_fetch_row($recordsid) ) { $runsql = "insert into " . $table2 . "(" . $fd2 . ") values (" ; for ( $i = 1 ; $i <= $idcounts ; $i ++) { $fdv = odbc_result($recordsid,$i) ;
if ( mysql_field_type($result,$i-1) == "string") $runsql .= "'". $fdv . "'," ;
else
$runsql .= $fdv. "," ; } $runsql = substr($runsql,0,strlen($runsql)-1) ; $runsql .= ")" ; mysql_query ($runsql) ; $theno++ ;
}
echo "Total Convert : " . $theno -- ; odbc_close($conn); ?> </body>
</html>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
我是这样转的:
1.用mysqlfront将表的数据存为txt文件
2.用sql server的导入与导出功能就可以转为access了不知有没有什么方法可以将全部的记录导出?
要先安装myodbc,建一个到mysql数据库的ODBC数据源,在access中导入,文件类型选ODBC,就可以了。