当前位置: 首页 > 图文教程 > 数据库 > MSSQL > ACCESS数据库向MySQL快速迁移小程序(二)

MSSQL
SQl 跨服务器查询语句
sql2005 HashBytes 加密函数
防止SQLSERVER的事件探查器跟踪软件
Excel导入Sqlserver数据库脚本
sql cast,convert,QUOTENAME,exec 函数学习记录
select into 和 insert into select 两种表复制语句
sqlserver 日志恢复方法(搞定drop和truncate)
海量数据库查询语句
DBCC CHECKIDENT 重置数据库标识列从某一数值开始
MSSQL 数据库同步教程
sql 语句中的 NULL值
判断一个表的数据不在另一个表中最优秀方法
SQL货币数字转英文字符语句
executesql 存储过程
sql 查询结果合并union all用法_数据库技巧
SQLServe 重复行删除方法
SQLServer 数据修复命令DBCC一览
SQLSERVERS 数据整理方法
根据多条件查询临时表 想得到不同结果集的方法
sqlServer 获取汉字字串的拼音声母

MSSQL 中的 ACCESS数据库向MySQL快速迁移小程序(二)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-30   浏览: 35 ::
收藏到网摘: n/a

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
以下为 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) )  {