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

MSSQL
如何在把超过固定长度的文字以……表示
精彩的近乎完美的分页存储过程
关于SQL Server SQL语句查询分页数据的解决方案
删除Access数词库中的空记录
在SQLSERVER2005中实现素数计算
经常用到的交叉表问题,一般用动态SQL能生成动态列!
sql server存储过程、存储函数的加密、解密
在SQL Server 2005中查询表结构及索引
取得拼音字头的存储过程
SQL Server自动备份无法删除过期的备份文件
未与信任SQL Server连接相关联的解决方法
小結SQL Server連接失敗錯誤及解決
SQL Server2000+JDBC常见问题及解决
PL/SQL实现Oracle数据库任务调度
Oracle中捕获问题SQL解决CPU过渡消耗
SQL Server 某些条件下求某日的日期
如何保持Oracle数据库的优良性能
SQL Server05 M 3.0 中复制和远程数据访问功能的技术对比
sql server平台用存储过程进行分页的两种方法
sql server 2000中循环插入100万条数据

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-30   浏览: 61 ::
收藏到网摘: 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) )  {