 |
ผมพยายามส่งข้อมูลจาก mysql ไปที่ MS access2013 แต่ส่งไม่ได้ไม่ทราบว่ามีท่านใดแนะนำได้บ้างครับ |
|
 |
|
|
 |
 |
|
<?php
// Connect to the MySQL database
include 'Dbconnect.php';
// Connect to the Microsoft Access database
//$access_conn = odbc_connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq={D:/IYARIN.accdb}", "", "");
$mdbFilename="D:/IYARIN.accdb";
$access_conn = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=$mdbFilename", "", "");
// Check the Microsoft Access connection
if (!$access_conn) {
die("Access connection failed: " . odbc_errormsg());
}
// Prepare and execute the SQL query
$sql = "SELECT * FROM Sale_tbl
WHERE Sale_tbl.T_date='2023-02-07'";
$result = mysqli_query($mysql_conn, $sql);
// Loop through the data and insert each record into the Microsoft Access database
while ($row = mysqli_fetch_assoc($result)) {
// Access the columns using the field names
$column1 = $row["T_date"];
$column2 = $row["CustID"];
$column3 = $row["Custname"];
// Prepare and execute the insert query
$insert_sql = "INSERT INTO Sale_tbl (SendDTE, CustID, ShopName) VALUES ('$column1', '$column2', '$column3')";
$insert_result = odbc_exec($access_conn, $insert_sql);
// Check the result of the insert query
if (!$insert_result) {
die("Insert query failed: " . odbc_errormsg());
}
}
// Free the result and close the connections
mysqli_free_result($result);
mysqli_close($mysql_conn);
odbc_close($access_conn);
?>
Tag : PHP, Ms Access, MySQL
|
|
 |
 |
 |
 |
Date :
2023-02-08 10:45:15 |
By :
โต้งครับ |
View :
355 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม้ได้ยังไง error ว่าอะไร?
|
 |
 |
 |
 |
Date :
2023-02-08 10:55:42 |
By :
009 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่มีข้อความใดเลยครับ ข้อมูลก็ไม่เข้าครับ
|
 |
 |
 |
 |
Date :
2023-02-08 10:57:26 |
By :
โต้งครับ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เป็นไปได้หลายสาเหตุ เช่น
1. ปัญหาของ connection (MySQL/ACCESS) ลองเช็ค user/pw ให้ถูกต้อง
2. อ้างอิงชื่อ table, column หรือ data type ใน INSERT statement ไม่ถูกต้อง
3. กำหนด path ของไฟล์ access ไม่ถูกต้อง
4. ไม่ได้เปิด write permission ใน access db
5. ไม่ได้กำหนดให้อนุญาตรับ data input ใน access db
หรือ อื่นๆ
ที่ไม่มีข้อความแจ้ง...การแสดง error อาจถูกปิดอยู่
ลองวางโค้ดนี้ไว้บนสุด รันใหม่แล้วนำ error มาดู
Code (PHP)
ini_set('display_errors', 1);
error_reporting(E_ALL);
|
 |
 |
 |
 |
Date :
2023-02-08 12:20:29 |
By :
009 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|