简体   繁体   English

将MySQL .sql文件转换为MS Access数据库

[英]Convert MySQL .sql file to MS Access Database

is there a way out to convert .sql to access database using php. 有没有一种方法可以将.sql转换为使用php访问数据库。 i have tried exporting the sql to csv format and then converting csv to access but only the data comes the column names are gone. 我曾尝试将sql导出为csv格式,然后将csv转换为access,但只有数据来了,列名不见了。

$sql=mysql_query("SELECT * FROM attendance WHERE (year = '" . mysql_real_escape_string($_SESSION['year']) . "') and ( branch= '" .
        mysql_real_escape_string(($_SESSION['branch'])). "') and ( sem= '" . mysql_real_escape_string(($_SESSION['sem'])). "') and (sec= '" .
        mysql_real_escape_string(($_SESSION['sec'])). "')"); 
print "<body background='bg.jpg'>"; 
Print "<br><br><BR><center><table border cellpadding=3><tr><th>idno</th><th>name</th><th>subject</th><th>Held Classes</th><th>Attended Classes</th></tr>";  
while($data=mysql_fetch_array( $sql ))   { 
    echo "<tr><td>".$data['idno']." </td><td>".$data['name'] . " <td>".$data['subject']." </td><td>".$data['heldcls'] . "<td>".$data['attendcls']." </td>"; 
} 
Print "</table><br><br><form action = excel.php method = POST><input type = 'submit' name = 'submit' Value = 'Export to excel'></form></center>";
<?php

$con=mysqli_connect("hostname", "dbuser", "dbpwd", "dbname");

$conn = new COM ("ADODB.Connection")
or die("Cannot start ADO");
$connStr = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=/onlineadmission.mdb;Jet OLEDB:Database Password=*********;";
  $conn->open($connStr);
$result = mysqli_query($con,"SELECT * FROM student");
$del="DELETE FROM student";
if ($conn->Execute($del) === false) {
         print 'error inserting: '.$conn->ErrorMsg().'<BR>';
}
while($row = mysqli_fetch_array($result))
  {
   $var1=$row[0];
 $sql="INSERT INTO student
VALUES
('$var1')";
if ($conn->Execute($sql) === false) {

         print 'error inserting: '.$conn->ErrorMsg().'<BR>';
}
  }
echo "records inserted";
?>

the $con variable is used for the mysql connection... the $conn (notice a another 'n') is used for the adodb connection that is the connection used for msaccess... Data source=/onlinead**.mdb.. this file is in c:/ $ con变量用于mysql连接... $ conn(注意另一个“ n”)用于adodb连接,该连接是用于msaccess的连接...数据源= / onlinead **。mdb。 。这个文件在c:/

the code first deletes all the records in the mdb file and then uploads whatever records present in phpmyadmin ie ur database... 代码首先删除mdb文件中的所有记录,然后上传phpmyadmin中存在的所有记录,即您的数据库...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM