Minggu …10… Page 1 Pemrograman Visual MINGGU Ke Sepuluh Pemrograman Visual Pemrograman Visual Pokok Bahasan: ADO .NET II Tujuan Instruksional Khusus: Mahasiswa dapat menjelaskan dan mengaplikasikan ADO .NET II pada Visual Basic 2008 Referensi: Deitel Deitel, Visual Basic 2008 (2009), How to Program, Prentice Hall. Chapter 20
13
Embed
Pemrograman VisualMinggu …10… Page 1 MINGGU Ke Sepuluh Pemrograman Visual Pokok Bahasan: ADO.NET II Tujuan Instruksional Khusus: Mahasiswa dapat menjelaskan.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Minggu …10… Page 1
Pemrograman Visual
MINGGU Ke Sepuluh
Pemrograman VisualPemrograman Visual
Pokok Bahasan:ADO .NET II
Tujuan Instruksional Khusus:Mahasiswa dapat menjelaskan dan mengaplikasikan ADO .NET II pada Visual Basic 2008
Referensi:Deitel Deitel, Visual Basic 2008 (2009), How to Program, Prentice Hall. Chapter 20
Pemrograman Visual Minggu …10… Page 2
Agenda
• Basic Select Query
• Where Clause
• Order By Clause
• Retrieving data from multiple TABLES: Inner join
• Insert Statement
• Update Statement
• Delete Statement
Pemrograman Visual Minggu …10… Page 3
Introduction
• A database is an integrated collection of data
• DBMS (Database Management System)
• SQL (Structured Query Language)
• Microsoft Access, Microsoft SQL, MySQL, Oracle, Dbase, Sybase, DB2
• Microsoft VB .NET
Pemrograman Visual Minggu …10… Page 4
Relational Database Model
• The relational database model is a logical representation of data that allows relationships among data to be considered without concern for the physical structure of the data
• Database, Tables, Records, Fields, Characters
• Database Specification
Pemrograman Visual Minggu …10… Page 5
Database• Database
– Tables
• Records
– Fields
» Chars
• Example of Table:
number name departmentsalary location23603 Jones 413 1100 New Jersey24568 Kerwin 413 2000 New Jersey34589 Larson 642 1800 Los Angles36761 Myers 611 1400 Orlando47132 Neumann 413 9000 New Jersey78321 Stephens 611 8500 Orlando
Pemrograman Visual Minggu …10… Page 6
Database Specification• Spesifikasi database adalah uraian atau deskripsi detail
atribute yang ada dalam masing-masing tables
• Example of database spesifikasi:
Nama Fields Type Length Deskripsinumer chars 5name chars 25department chars 3salary number/integer 9location chars 15
Pemrograman Visual Minggu …10… Page 7
Book DatabaseAuthorsauthorID firstName lastName
1 Harvey Deitel2 Paul Deitel3 Tem Neito4 Kate Steinbuhler5 Sean Santry6 Ted Lin7 Praveen Sadhu8 David MePhie9 Cheryl Yaeger
10 Marina Zlatkina11 Ben Wiedermann12 Jonathan Liperi
• Select * from tablename• Select * from authors• Select authorID, lastname from Authors• Select * from authorISBN Where authorID=‘1’• Select * from Publishers Where publisherName like ‘D*’• * = one or more characters, ? = one characters• Select authorsID, firstName order by firsName ASC• Select fieldName1, fieldName2 From table1 inner join
• Update tablename set fieldname1=value1, fieldname2=value2, fieldname3=value3 where criteria
• Delete From tablename where criteria
Pemrograman Visual Minggu …10… Page 10
Connection to DatabaseImports System.Data.OleDbImports System.DataImports System.Data.SqlClient
Public Class Form1
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Dim str As String
Dim icount As Integer cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:try.mdb;") cn.Open() str = "select * from MstMtKuliah where kdmtk='" & txtkdmtk.Text & "'" cmd = New OleDbCommand(str, cn) dr = cmd.ExecuteReader dr.hasrow() dr.read() messagebox.show(dr(0))
Pemrograman Visual Minggu …10… Page 11
Connection to Database
cn = New OleDbConnection("Provider= Microsoft.Jet.OLEDB.4.0;Data Source= d: try.mdb;”)
cn.Open()str = "update MstMtKuliah set nmmtk='" & txtmatakuliah.Text & "',sks="
& txtsks.Text & " where kdmtk='" & txtkdmtk.Text & "'"'string stores the command and CInt is used to convert number to string cmd = New OleDbCommand(str, cn)icount = cmd.ExecuteNonQueryMessageBox.Show("Data berhasil di update") Kosong_Form()