280 likes | 410 Vues
This document outlines the key concepts and practical examples in database design and development using Visual Basic. It covers connecting to a database, executing SQL commands, and manipulating data within the `dbEmployee` database. Key operations include retrieving employee records, inserting new records, and updating existing entries through user input. It serves as a guide for students to develop skills in handling data using ADO with SQL statements, ensuring they understand Data Manipulation Language (DML) principles necessary for effective database management.
E N D
DBMATRIX Reloaded เอกสารประกอบการบรรยายรายวิชา 204204 การออกแบบและพัฒนาฐานข้อมูล
Visual Basic With Database dbEmployee Determine Database Connect to the Database dbEmployee Execute Command SELECT * FROM employee Use Data Close Connection
Visual Basic With Database Determine Database Set conAddress = New ADODB.Connection conAddress.ConnectionString = "PROVIDER=SQLOLEDB;DATA SOURCE=LAB10;UID=user01;PWD=password;DATABASE=dbEmployee"
Visual Basic With Database Connect to the Database conAddress.Open
Visual Basic With Database Execute Command Set rstAddress = New ADODB.Recordset rstAddress.Open "SELECT * FROM employee ORDER BY empname", conAddress, adOpenStatic, adLockOptimistic
Visual Basic With Database Use Data Set DataGrid1.DataSource = rstAddress
Visual Basic With Database Close Connection rstAddress.Close Set rstAddress = Nothing conAddress.Close Set conAddress = Nothing
Visual Basic With Database Determine Database Connect to the Database Execute Command Use Data Close Connection
SQL Statement in Visual Basic • SQL_Statement = "SELECT * FROM employee ORDER BY empname WHERE empname LIKE '" & Text1.Text & "'" • SQL_Statement = "INSERT INTO employee (empno, empname, address) VALUES('" & Text1.Text & "','" & Text2.Text & "','" & Text3.Text & "')" • SQL_Statement = "UPDATE employee SET empno='" & Text2.Text & "' WHERE empno = '" & Text1.Text & "'"
SQL Statement in Visual Basic • SQL_Statement = "SELECT * FROM employee ORDER BY empname WHERE empname LIKE '" & Text1.Text & "'"
SQL Statement in Visual Basic • SQL_Statement = "SELECT * FROM employee ORDER BY empname WHERE empname LIKE ‘” & Text1.Text & “’” • SELECT * FROM employee ORDER BY empname WHERE empname LIKE ‘somchai’
SQL Statement in Visual Basic • SQL_Statement = "INSERT INTO employee (empno, empname, address) VALUES('" & Text1.Text & "','" & Text2.Text & "','" & Text3.Text & "')"
SQL Statement in Visual Basic • SQL_Statement = "INSERT INTO employee (empno, empname, address) VALUES('" & Text1.Text & "','" & Text2.Text & "','" & Text3.Text & "')" • INSERT INTO employee (empno, empname, address) VALUES(“0001”, “Somchai”, “111 Univers…”)
SQL Statement in Visual Basic • SQL_Statement = "UPDATE employee SET empno='" & Text2.Text & "' WHERE empno = '" & Text1.Text & "'"
SQL Statement in Visual Basic • SQL_Statement = "UPDATE employee SET empname='" & Text2.Text & "' WHERE empno = '" & Text1.Text & "'" • UPDATE employee SET empname = ‘Somsak’ WHERE empno = ‘0001’
ภาษาสำหรับจัดการข้อมูล Data Manipulation Language (DML)
ภาษาสำหรับจัดการข้อมูล Data Manipulation Language (DML)
ภาษาสำหรับจัดการข้อมูล Data Manipulation Language (DML) book rental member
ภาษาสำหรับจัดการข้อมูล Data Manipulation Language (DML) book rental member
ภาษาสำหรับจัดการข้อมูล Data Manipulation Language (DML) book rental member
ภาษาสำหรับจัดการข้อมูล Data Manipulation Language (DML) member rental r book
ภาษาสำหรับจัดการข้อมูล Data Manipulation Language (DML) SELECT member.name, book.book_name FROM member, rental, book WHERE member.member_id = rental.member_id AND rental.book_id = book.book_id
ภาษาสำหรับจัดการข้อมูล Data Manipulation Language (DML) member rental r book SELECT member.name, book.book_name FROM member, rental, book WHERE member.member_id = rental.member_id AND rental.book_id = book.book_id
ภาษาสำหรับจัดการข้อมูล Data Manipulation Language (DML) SELECT member.name, book.book_name FROM member, rental, book WHERE member.member_id = rental.member_id AND rental.book_id = book.book_id
สอบเก็บคะแนนครั้งที่ 2(5 คะแนน) • ให้นักศึกษาจับคู่ทำการบ้านครั้งที่ 4 ซึ่งจะมีให้ดาวน์โหลดในวันพุธที่ 10 พ.ย. 2547 • นักศึกษาไม่ควรใช้เวลาเกินครึ่งชั่วโมงในการทำ • นักศึกษาที่ลอกคู่อื่นจะถูกดำเนินคดีตามที่อาจารย์สถิตย์โชคและนีโอบัญญติไว้สูงสุด • จันทร์หน้า 15 พ.ย. 2547