有没有什么好方法将mysql 转为access?

我有一个sql2accd,但是demo版,不能将所有的数据转为access!不知各位有没有什么好方法?
---------------------------------------------------------------

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步,直至迁移所有的表,

1以下为 fdlist.php源程序   
  1<html>
  2<head>
  3<style type="text/css">   
  4body,td,li,div,p,pre,a,b,h1,h2,h3,h4 {font-family:verdana;font-size:9pt;line-height : 18px;color:#a00000 }   
  5</style>
  6</head>
  7<?   
  8  
  9$dbconnection = @mysql_connect("yourmysqlserver", "mysqlaccount", "mysqlpassword")   
 10  
 11or die ("can not connect to database server");   
 12  
 13@mysql_select_db("yourdatabase")   
 14  
 15or die("<p style='font-size:9pt;font-family:verdana;color:#803333;font-weight:bold'>No Database,") ;   
 16  
 17$odbc_table = "youroriginaltable" ; // The original table name in your ODBC database   
 18  
 19$mysql_table = "yournewtable" ; // The new table name in your Mysql Database.   
 20  
 21  
 22  
 23?&gt;   
 24  
 25<body bgcolor="#f0f0f0" leftmargin="0" text="#a00000" topmargin="0">
 26<br/>
 27<div style="font-size:24pt;font-family:times;font-weight:bold;color:#00a000">Fields List of Two tables</div>
 28<hr color="#900000" size="1"/>
 29<?   
 30  
 31$conn = odbc_connect("task", "", "");   
 32  
 33$odbc_query = "select * from " . $odbc_table . " where 1=2";   
 34  
 35$recordsid = odbc_exec($conn, $odbc_query);   
 36  
 37$idcounts = odbc_num_fields( $recordsid ) ;   
 38  
 39$fdlist1 = "" ;   
 40  
 41for ( $i = 1 ; $i <= $idcounts ; $i ++)   
 42  
 43$fdlist1 .= odbc_field_name($recordsid,$i)."," ;   
 44  
 45echo "<div> Fd1 = " . $fdlist1 ;   
 46  
 47$fdlist1 = substr($fdlist1,0,strlen($fdlist1)-1) ;   
 48  
 49$fdlist2 = "" ;   
 50  
 51  
 52$sqlquery = "select * from " . $mysql_table . " where 1=2 " ;   
 53  
 54$records2 = mysql_query ($sqlquery) ;   
 55  
 56$idcount2 = mysql_num_fields ( $records2 ) ;   
 57  
 58  
 59  
 60for ( $i = 0 ; $i &lt; $idcount2 ; $i++)   
 61  
 62$fdlist2 .= mysql_field_name($records2,$i )."," ;   
 63  
 64echo "<div> FD2 = " . $fdlist2 ;   
 65  
 66$fdlist2 = substr($fdlist2,0,strlen($fdlist2)-1) ;   
 67  
 68$fp = fopen ("fdlist.txt","w") ;   
 69  
 70fwrite ($fp,$ctable) ;   
 71  
 72fwrite ($fp,"n");   
 73  
 74fwrite ($fp,$fdlist1) ;   
 75  
 76fwrite ($fp,"n");   
 77  
 78fwrite ($fp,$etable) ;   
 79  
 80fwrite ($fp,"n") ;   
 81  
 82fwrite ($fp,$fdlist2) ;   
 83  
 84fclose($fp) ;   
 85  
 86odbc_close($conn);   
 87  
 88if ( $idcount2 != $idcounts ) {   
 89  
 90echo "<hr color="#900000" size="1"/>".   
 91  
 92"<div style="font-size:20pt;font-family:times;font-weight:bold"> The fields of two tables doesn't match" ;   
 93  
 94echo "<br/><br/>ODBC_table Fields = " . $idcounts;   
 95  
 96echo "<br/><br/>MySQL_table Fields = " . $idcount2;   
 97}   
 98?&gt;   
 99  
100  
101</div></div></body>
102</html>
1未完接(二)   
2  

以下为 import.php 源程序

  1```
  2<html>
  3<head>
  4<style type="text/css">   
  5body,td,li,div,p,pre,a,b,h1,h2,h3,h4 {font-family:verdana;font-size:9pt;line-height : 18px;color:#a00000 }   
  6</style>
  7</head>
  8<body bgcolor="#f0f0f0" leftmargin="0" text="#a00000" topmargin="0">
  9<center>
 10<div style="font-size:24pt;font-family:times;font-weight:bold;color:#008000">ODBC --&gt; MySQL Migrant</div>
 11<hr color="#900000" size="1"/>
 12<?   
 13  
 14$dbconnection = @mysql_connect("yourmysqlserver", "mysqlaccount", "mysqlpassword")   
 15  
 16or die ("can not connect to database server");   
 17  
 18@mysql_select_db("yourdatabase")   
 19  
 20or die("<p style='font-size:9pt;font-family:verdana;color:#803333;font-weight:bold'>No Database,") ;   
 21  
 22  
 23$conn = odbc_connect("task", "", "");   
 24  
 25$fp = fopen ("fdlist.txt","r") ;   
 26  
 27$table1 = fgets($fp,200);   
 28  
 29$fd1 = fgets($fp,1024) ;   
 30  
 31$table2 = fgets($fp,200);   
 32  
 33$fd2 = fgets($fp,1024) ;   
 34  
 35  
 36$query1 = "select " . $fd1 . " from " . $table1 ;   
 37  
 38$query2 = "select " . $fd2 . " from " . $table2 . " where 1=2 " ;   
 39  
 40$result = mysql_query ($query2) ;   
 41  
 42mysql_query ("delete from " .$table2 ) ;   
 43  
 44echo "sql=". $query1;   
 45  
 46$recordsid = odbc_exec($conn, $query1);   
 47  
 48$idcounts = odbc_num_fields( $recordsid ) ;   
 49  
 50$idcount2 = mysql_num_fields($result) ;   
 51  
 52if ( $idcounts != $idcount2 )   
 53die (" The fields of two tables doesn't match ") ;   
 54  
 55echo "<table border="1" bordercolordark="#ffffff" bordercolorlight="#000000" cellpadding="3" cellspacing="0" width="90%">n" ;   
 56  
 57  
 58  
 59echo "<tr align="center"><td> n " ;   
 60  
 61for ( $i = 1 ; $i &lt;= $idcounts ; $i ++)   
 62  
 63echo "n<td>" . odbc_field_name($recordsid,$i) ;   
 64  
 65$theno = 1 ;   
 66  
 67echo "<tr>n" ;   
 68  
 69  
 70  
 71while (odbc_fetch_row($recordsid) ) {   
 72  
 73  
 74  
 75$runsql = "insert into " . $table2 . "(" . $fd2 . ") values (" ;   
 76  
 77for ( $i = 1 ; $i &lt;= $idcounts ; $i ++) {   
 78  
 79$fdv = odbc_result($recordsid,$i) ;   
 80  
 81  
 82if ( mysql_field_type($result,$i-1) == "string")   
 83  
 84$runsql .= "'". $fdv . "'," ;   
 85else   
 86$runsql .= $fdv. "," ;   
 87  
 88}   
 89  
 90$runsql = substr($runsql,0,strlen($runsql)-1) ;   
 91  
 92$runsql .= ")" ;   
 93  
 94mysql_query ($runsql) ;   
 95  
 96$theno++ ;   
 97}   
 98  
 99  
100echo "Total Convert : " . $theno -- ;   
101  
102  
103  
104odbc_close($conn);   
105  
106?&gt;   
107  
108</tr></td></td></tr></table></center></body>
109</html>
110```
111~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
112  
113  
114\---------------------------------------------------------------   
115  
116当然有,直接用access就可以导入mysql数据库。   
117要先安装myodbc,建一个到mysql数据库的ODBC数据源,在access中导入,文件类型选ODBC,就可以了。   
118  
119\---------------------------------------------------------------   
120  
121楼上说的并不是完全的转换,因为如果你删了mysql,那导入的数据库就不能用了。   
122  
123我的看法就是把mysql导出为带有tab的文本文件,然后用access读入这些数据,也可以写程序来完成读写。
Published At
Categories with 数据库类
Tagged with
comments powered by Disqus