--NOTE: If your computer does not come with database drivers, you must first
--install the 32-bit Microsoft Access drivers.
--************************************************************************
--First, attempt to open a connection to this database as a DSN connection
--This will work if the student.mdb file has been set up as a 32-bit
--Microsoft Access data source.
--The data source should be named Students Database or change its value
--in the lines below.
-- Open a connection to an ODBC data source.
DB_DatabaseName:="Students Database"
--Clear any error messages that might be in the error variable
DB_ODBCError:=""
--Open a handle to the data source. Pass the Authorware window handle, the variable you want to use for error messages, the data source
--name, the database user name, and the password if any.
DB_ODBCHandle := ODBCOpen(WindowHandle,"DB_ODBCError",DB_DatabaseName,"admin","")
--************************************************************************
--check to see if that was successful. If not, open a DSNless connection
--to the database (assumes the database is in the same directory as this file)
if DB_ODBCHandle=0 then
--create a connection string
--Connection strings vary depending on your database type.
--For more on connection strings, visit
--http://www.able-consulting.com/ADO_Conn.htm
DB_ODBCpath := FileLocation^"student.mdb"
DB_ODBCuser := "Admin"
DB_ODBCpwd := ""
DB_ODBCdriver := "Driver={Microsoft Access Driver (*.mdb)};"
DB_ODBCconnect := DB_ODBCdriver
DB_ODBCconnect := DB_ODBCconnect^"DBQ="^DB_ODBCpath^";"
DB_ODBCconnect := DB_ODBCconnect ^ "UID=" ^ DB_ODBCuser ^ ";"
DB_ODBCconnect := DB_ODBCconnect ^ "PWD=" ^ DB_ODBCpwd ^ ";"
--connect using the connection string
DB_ODBCHandle := ODBCOpenDynamic(WindowHandle, "DB_ODBCError", DB_ODBCconnect)
end if
-หมายเหตุ: ถ้าคอมพิวเตอร์ของคุณไม่มีโปรแกรมควบคุมฐานข้อมูล คุณต้อง-ติดตั้งโปรแกรมควบคุม Microsoft Access 32 บิต--************************************************************************-ก่อนอื่น พยายามเปิดการเชื่อมต่อกับฐานข้อมูลนี้เป็นการเชื่อมต่อ DSN-นี้จะทำงานถ้าแฟ้ม student.mdb ถูกตั้งเป็น 32 บิต-แหล่งข้อมูล Microsoft Access-แหล่งข้อมูลควรมีการตั้งชื่อฐานข้อมูลนักเรียน หรือเปลี่ยนค่าของ-ในบรรทัดด้านล่าง-เปิดการเชื่อมต่อกับแหล่งข้อมูล ODBCDB_DatabaseName: = "ฐานข้อมูลนักเรียน"-ลบข้อผิดพลาดที่อาจอยู่ในตัวแปรข้อผิดพลาดDB_ODBCError: = ""-เปิดหมายเลขอ้างอิงกับแหล่งข้อมูล ผ่านมือจับหน้าต่าง Authorware ตัวแปรที่คุณต้องการใช้สำหรับข้อความข้อผิดพลาด แหล่งข้อมูล-ชื่อ ชื่อผู้ใช้ฐานข้อมูล และรหัสผ่านถ้ามีการDB_ODBCHandle: = ODBCOpen(WindowHandle,"DB_ODBCError",DB_DatabaseName,"admin","")--************************************************************************-ตรวจสอบเพื่อดูถ้าที่ประสบความสำเร็จ ถ้า ไม่ได้ เปิดการเชื่อมต่อแบบ DSNless-ฐานข้อมูล (ถือเป็นฐานข้อมูลในไดเรกทอรีเดียวกันเป็นแฟ้มนี้)ถ้า DB_ODBCHandle = 0 แล้ว -สร้างสายอักขระการเชื่อมต่อ -เชื่อมต่อสตริงที่แตกต่างกันไปขึ้นอยู่กับชนิดของฐานข้อมูล -สำหรับข้อมูลเพิ่มเติมเกี่ยวกับสตริงการเชื่อมต่อ -http://www.able-consulting.com/ADO_Conn.htm DB_ODBCpath: = FileLocation^"student.mdb " DB_ODBCuser: = "Admin" DB_ODBCpwd: = "" DB_ODBCdriver: = "โปรแกรมควบคุม = {Microsoft Access โปรแกรมควบคุม (*.mdb) }; " DB_ODBCconnect: = DB_ODBCdriver DB_ODBCconnect: = DB_ODBCconnect ^ " DBQ =" ^ DB_ODBCpath ^ DB_ODBCconnect: = DB_ODBCconnect ^ " UID =" ^ DB_ODBCuser ^ DB_ODBCconnect: = DB_ODBCconnect ^ " PWD =" ^ DB_ODBCpwd ^ -เชื่อมต่อโดยใช้สายอักขระการเชื่อมต่อ DB_ODBCHandle: = ODBCOpenDynamic (WindowHandle, "DB_ODBCError", DB_ODBCconnect)สิ้นสุดถ้า
การแปล กรุณารอสักครู่..
