Escolar Documentos
Profissional Documentos
Cultura Documentos
ADO adalah teknologi Microsoft, dan singkatan dari ActiveX Data Objects.
In our ADO tutorial you will learn how to use ADO to access databases from your Web site.
Dalam ADO tutorial kami anda akan mempelajari bagaimana menggunakan ADO untuk
mengakses database dari situs Web Anda.
ADO Pendahuluan
ADO dapat digunakan untuk mengakses database dari halaman web Anda.
What you should already know Apa yang sudah Anda harus tahu
Before you continue you should have a basic understanding of the following: Sebelum Anda
melanjutkan, Anda harus memiliki pemahaman dasar sebagai berikut:
WWW, HTML and the basics of building Web pages WWW, HTML dan dasar-dasar
pembangunan halaman web
Active Server Pages (ASP) Active Server Pages (ASP)
Structured Query Language (SQL) Structured Query Language (SQL)
If you want to study these subjects first, go to our Home page Jika Anda ingin mempelajari mata
pelajaran pertama, kami pergi ke Home page
The common way to access a database from inside an ASP page is to: Cara umum untuk
mengakses database dari dalam halaman ASP adalah untuk:
The easiest way to connect to a database is to use a DSN-less connection. Cara termudah untuk
terhubung ke database adalah dengan menggunakan koneksi DSN-kurang. A DSN-less
connection can be used against any Microsoft Access database on your web site. Sebuah DSN-
connection kurang dapat digunakan terhadap setiap database Microsoft Access di situs web
Anda.
If you have a database called "northwind.mdb" located in a web directory like "c:/webdata/", you
can connect to the database with the following ASP code: Jika Anda memiliki database yang
disebut "northwind.mdb" terletak di direktori web seperti "c: webdata / /", Anda dapat terhubung
ke database dengan kode ASP berikut:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
%>
Note, from the example above, that you have to specify the Microsoft Access database driver
(Provider) and the physical path to the database on your computer.
Create an ODBC Database Connection
If you have an ODBC database called "northwind" you can connect to the database with the
following ASP code:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Open "northwind"
%>
With an ODBC connection, you can connect to any database, on any computer in your network,
as long as an ODBC connection is available.
Note that this configuration has to be done on the computer where your web site is located. If
you are running Personal Web Server (PWS) or Internet Information Server (IIS) on your own
computer, the instructions above will work, but if your web site is located on a remote server,
you have to have physical access to that server, or ask your web host to do this for you.
The ADO Connection object is used to create an open connection to a data source. Through this
connection, you can access and manipulate a database.
ADO Recordset
Untuk dapat membaca data database, data pertama harus dimuat ke recordset.
Create an ADO Table Recordset Buat Recordset ADO Tabel
After an ADO Database Connection has been created, as demonstrated in the previous chapter, it
is possible to create an ADO Recordset. Setelah ADO Database Connection telah dibuat, seperti
diperlihatkan dalam bab sebelumnya, adalah mungkin untuk membuat sebuah Recordset ADO.
Suppose we have a database named "Northwind", we can get access to the "Customers" table
inside the database with the following lines: Misalkan kita memiliki database bernama
"Northwind", kita bisa mendapatkan akses ke meja "Pelanggan" di dalam database dengan baris
berikut:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Customers", conn
%>
We can also get access to the data in the "Customers" table using SQL:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Customers", conn
%>
Extract Data from the Recordset
Suppose we have a database named "Northwind", we can get access to the "Customers" table
inside the database with the following lines:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Customers", conn
The ADO Recordset object is used to hold a set of records from a database table.
ADO Tampilan
Cara yang paling umum untuk menampilkan data dari recordset, adalah untuk menampilkan data
dalam tabel HTML.
Display the Field Names and Field Values Nama Tampilan Lapangan dan Nilai
Field
We have a database named "Northwind" and we want to display the data from the "Customers"
table (remember to save the file with an .asp extension): Kami memiliki database bernama
"Northwind" dan kami ingin menampilkan data dari tabel "Pelanggan" (ingat untuk menyimpan
file dengan ekstensi asp.):
Example Contoh
<html>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT * FROM Customers", conn
do until rs.EOF
for each x in rs.Fields
Response.Write(x.name)
Response.Write(" = ")
Response.Write(x.value & "<br />")
next
Response.Write("<br />")
rs.MoveNext
loop
rs.close
conn.close
%>
</body>
</html>
Show example »
Display the Field Names and Field Values in an HTML Table
We can also display the data from the "Customers" table inside an HTML table with the
following lines (remember to save the file with an .asp extension):
Example
<html>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT Companyname, Contactname FROM Customers", conn
%>
</body>
</html>
Show example »
Add Headers to the HTML Table
We want to add headers to the HTML table to make it more readable (remember to save the file
with an .asp extension):
Example
<html>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs = Server.CreateObject("ADODB.recordset")
sql="SELECT Companyname, Contactname FROM Customers"
rs.Open sql, conn
%>
</body>
</html>
Show example »
More Examples
ADO Query
Kita dapat menggunakan SQL untuk membuat query untuk menentukan hanya satu set yang
dipilih dari catatan dan bidang untuk melihat.
We want to display only the records from the "Customers" table that have a "Companyname"
that starts with an A (remember to save the file with an .asp extension): Kami ingin
menampilkan hanya record dari tabel "Pelanggan" yang memiliki "CompanyName" yang
dimulai dengan A (ingat untuk menyimpan file dengan ekstensi asp.):
Example Contoh
<html>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs=Server.CreateObject("ADODB.recordset")
sql="SELECT Companyname, Contactname FROM Customers
WHERE CompanyName LIKE 'A%'"
rs.Open sql, conn
%>
</body>
</html>
Show example »
More Examples
ADO Urutkan
Kita dapat menggunakan SQL untuk menentukan cara untuk menyortir data dalam mengatur
catatan.
We want to display the "Companyname" and "Contactname" fields from the "Customers" table,
ordered by "Companyname" (remember to save the file with an .asp extension): Kami ingin
menampilkan "CompanyName" dan "Contactname" kolom dari tabel "Pelanggan", diperintahkan
oleh "CompanyName" (ingat untuk menyimpan file dengan ekstensi asp.):
Example Contoh
<html>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs = Server.CreateObject("ADODB.recordset")
sql="SELECT Companyname, Contactname FROM
Customers ORDER BY CompanyName"
rs.Open sql, conn
%>
</body>
</html>
Show example »
More Examples
We want to add a new record to the Customers table in the Northwind database. Kami ingin
menambahkan catatan baru ke dalam tabel Nasabah dalam database Northwind. We first create a
form that contains the fields we want to collect data from: Pertama-tama kita membuat form
yang berisi bidang kita ingin mengumpulkan data dari:
<html>
<body>
</body>
</html>
When the user presses the submit button the form is sent to a file called "demo_add.asp". The
"demo_add.asp" file contains the code that will add a new record to the Customers table:
<html>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
</body>
</html>
Important
If the table contains a primary key, make sure to append a unique, non-Null value to the primary
key field (if not, the provider may not append the record, or an error occurs)
If the table contains an AutoNumber field, do not include this field in the SQL INSERT command
(the value of this field will be taken care of automatically by the provider)
In a MS Access database, you can enter zero-length strings ("") in Text, Hyperlink, and Memo
fields IF you set the AllowZeroLength property to Yes.
Note: Not all databases support zero-length strings and may cause an error when a record with
blank fields is added. It is important to check what data types your database supports.
We want to update a record in the Customers table in the Northwind database. Kami ingin
memperbarui catatan dalam tabel Nasabah dalam database Northwind. We first create a table that
lists all records in the Customers table: Pertama-tama kita membuat tabel yang berisi daftar
semua catatan dalam tabel Pelanggan:
<html>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "SELECT * FROM customers",conn
%>
<h2>List Database</h2>
<table border="1" width="100%">
<tr>
<%
for each x in rs.Fields
response.write("<th>" & ucase(x.name) & "</th>")
next
%>
</tr>
<% do until rs.EOF %>
<tr>
<form method="post" action="demo_update.asp">
<%
for each x in rs.Fields
if lcase(x.name)="customerid" then%>
<td>
<input type="submit" name="customerID" value="<%=x.value%>">
</td>
<%else%>
<td><%Response.Write(x.value)%></td>
<%end if
next
%>
</form>
<%rs.MoveNext%>
</tr>
<%
loop
conn.close
%>
</table>
</body>
</html>
If the user clicks on the button in the "customerID" column he or she will be taken to a new file
called "demo_update.asp". The "demo_update.asp" file contains the source code on how to
create input fields based on the fields from one record in the database table. It also contains a
"Update record" button that will save your changes:
<html>
<body>
<h2>Update Record</h2>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
cid=Request.Form("customerID")
if Request.form("companyname")="" then
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "SELECT * FROM customers WHERE customerID='" & cid & "'",conn
%>
<form method="post" action="demo_update.asp">
<table>
<%for each x in rs.Fields%>
<tr>
<td><%=x.name%></td>
<td><input name="<%=x.name%>" value="<%=x.value%>"></td>
<%next%>
</tr>
</table>
<br /><br />
<input type="submit" value="Update record">
</form>
<%
else
sql="UPDATE customers SET "
sql=sql & "companyname='" & Request.Form("companyname") & "',"
sql=sql & "contactname='" & Request.Form("contactname") & "',"
sql=sql & "address='" & Request.Form("address") & "',"
sql=sql & "city='" & Request.Form("city") & "',"
sql=sql & "postalcode='" & Request.Form("postalcode") & "',"
sql=sql & "country='" & Request.Form("country") & "'"
sql=sql & " WHERE customerID='" & cid & "'"
on error resume next
conn.Execute sql
if err<>0 then
response.write("No update permissions!")
else
response.write("Record " & cid & " was updated!")
end if
end if
conn.close
%>
</body>
</html>
We want to delete a record in the Customers table in the Northwind database. Kami ingin
menghapus record di tabel Nasabah dalam database Northwind. We first create a table that lists
all records in the Customers table: Pertama-tama kita membuat tabel yang berisi daftar semua
catatan dalam tabel Pelanggan:
<html>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "SELECT * FROM customers",conn
%>
<h2>List Database</h2>
<table border="1" width="100%">
<tr>
<%
for each x in rs.Fields
response.write("<th>" & ucase(x.name) & "</th>")
next
%>
</tr>
<% do until rs.EOF %>
<tr>
<form method="post" action="demo_delete.asp">
<%
for each x in rs.Fields
if x.name="customerID" then%>
<td>
<input type="submit" name="customerID" value="<%=x.value%>">
</td>
<%else%>
<td><%Response.Write(x.value)%></td>
<%end if
next
%>
</form>
<%rs.MoveNext%>
</tr>
<%
loop
conn.close
%>
</table>
</body>
</html>
If the user clicks on the button in the "customerID" column he or she will be taken to a new file
called "demo_delete.asp". The "demo_delete.asp" file contains the source code on how to create
input fields based on the fields from one record in the database table. It also contains a "Delete
record" button that will delete the current record:
<html>
<body>
<h2>Delete Record</h2>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
cid=Request.Form("customerID")
if Request.form("companyname")="" then
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "SELECT * FROM customers WHERE customerID='" & cid & "'",conn
%>
<form method="post" action="demo_delete.asp">
<table>
<%for each x in rs.Fields%>
<tr>
<td><%=x.name%></td>
<td><input name="<%=x.name%>" value="<%=x.value%>"></td>
<%next%>
</tr>
</table>
<br /><br />
<input type="submit" value="Delete record">
</form>
<%
else
sql="DELETE FROM customers"
sql=sql & " WHERE customerID='" & cid & "'"
on error resume next
conn.Execute sql
if err<>0 then
response.write("No update permissions!")
else
response.write("Record " & cid & " was deleted!")
end if
end if
conn.close
%>
</body>
</html>
ADO Demonstrasi
Untuk menunjukkan aplikasi nyata kehidupan ADO kecil, kami telah mengumpulkan beberapa
ADO demo.
If you try to update the database, you will get the error message: "You do not have permission to
update this database". Jika Anda mencoba untuk memperbarui database, Anda akan
mendapatkan pesan kesalahan: "Anda tidak memiliki izin untuk memperbarui basis data". You
get this error because you don't have write access to our server. Anda mendapatkan kesalahan ini
karena Anda tidak memiliki akses tulis ke server kami.
BUT, if you copy the code and run it on your own system, you might get the same error.
NAMUN, jika Anda menyalin kode dan menjalankannya pada sistem Anda sendiri, Anda
mungkin mendapatkan kesalahan yang sama. That is because the system might see you as an
anonymous internet user when you access the file via your browser. Itu karena sistem akan
melihat Anda sebagai pengguna internet anonim saat Anda mengakses file melalui browser
Anda. In that case, you have to change the access-rights to get access to the file. Dalam hal ini,
Anda harus mengubah akses-hak untuk mendapatkan akses ke file.
How to change the access-rights of your Access database? Bagaimana mengubah hak akses
dari database Access Anda?
Open Windows Explorer, find the .mdb file. Buka Windows Explorer, cari file. Mdb. Right-click
on the .mdb file and select Properties. Klik kanan pada file mdb dan. Pilih Properties. Go to the
Security tab and set the access-rights here. Buka tab Security dan mengatur akses-hak di sini.
List, Edit, Update, and Delete Database Records Daftar, Edit, Update, dan
Delete Records Database
List, edit, update, and delete database records Daftar, edit, update, dan menghapus catatan
database
The following example demonstrates one way of how to display a database query in an HTML
table: Contoh berikut menunjukkan salah satu cara bagaimana untuk menampilkan query basis
data dalam sebuah tabel HTML:
<html>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT Companyname, Contactname FROM Customers", conn
%>
<%
rs.close
conn.close
set rs = Nothing
set conn = Nothing
%>
</body>
</html>
For a large query, this can slow down the script processing time, since many Response.Write
commands must be processed by the server.
The solution is to have the entire string created, from <table> to </table>, and then output it -
using Response.Write just once.
The GetString() method allows you to display the string with only one Response.Write. It also
eliminates the do...loop code and the conditional test that checks if the recordset is at EOF.
Syntax
str = rs.GetString(format,rows,coldel,rowdel,nullexpr)
To create an HTML table with data from a recordset, we only need to use three of the parameters
above (all parameters are optional):
Note: The GetString() method is an ADO 2.0 feature. You can download ADO 2.0 at
http://www.microsoft.com/data/download.htm .
In the following example we will use the GetString() method to hold the recordset as a string:
Example
<html>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT Companyname, Contactname FROM Customers", conn
str=rs.GetString(,,"</td><td>","</td></tr><tr><td>"," ")
%>
<%
rs.close
conn.close
set rs = Nothing
set conn = Nothing
%>
</body>
</html>
Show example »
ASP Sumber:
<html>
<body> <body>
<% <%
set conn=Server.CreateObject("ADODB.Connection") set conn = Server.CreateObject
("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb")) conn.Open (Server.Mappath ("/ db /
northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset") set rs = Server.CreateObject
("ADODB.Recordset")
rs.Open "SELECT Companyname, Contactname FROM Customers", conn rs.Open "SELECT
CompanyName, Contactname DARI Pelanggan", conn
str=rs.GetString(,,"</td><td>","</td></tr><tr><td>"," ") str = (,,"</ rs.GetString td>
<td> ","</ td> </ tr> <tr> <td> "," ")
%> %>
<% <%
rs.close rs.close
conn.close conn.close
set rs = Nothing set rs = Tidak ada
set conn = Nothing set conn = Tidak ada
%> %>
The ADO Command object is used to execute a single query against a database. ADO Command
object digunakan untuk menjalankan sebuah query tunggal terhadap database. The query can
perform actions like creating, adding, retrieving, deleting or updating records. Query dapat
melakukan tindakan seperti membuat, menambahkan, mengambil, menghapus atau memperbarui
catatan.
If the query is used to retrieve data, the data will be returned as a RecordSet object. Jika query
digunakan untuk mengambil data, data akan dikembalikan sebagai objek Recordset. This means
that the retrieved data can be manipulated by properties, collections, methods, and events of the
Recordset object. Ini berarti bahwa data yang diambil dapat dimanipulasi dengan properti,
koleksi, metode, dan peristiwa dari object Recordset.
The major feature of the Command object is the ability to use stored queries and procedures with
parameters. Fitur utama dari object Command adalah kemampuan untuk menggunakan query
disimpan dan prosedur dengan parameter.
ProgID PROGID
set objCommand=Server.CreateObject("ADODB.command")
Properties
Property Description
State Returns a value that describes if the Command object is open, closed,
connecting, executing or retrieving data
Methods
Method Description
Collections
Collection Description
The ADO Connection Object is used to create an open connection to a data source. Objek
Connection ADO digunakan untuk membuat koneksi terbuka untuk sumber data. Through this
connection, you can access and manipulate a database. Melalui sambungan ini, Anda dapat
mengakses dan memanipulasi database.
If you want to access a database multiple times, you should establish a connection using the
Connection object. Jika Anda ingin mengakses database beberapa kali, Anda harus membuat
sambungan menggunakan object Connection. You can also make a connection to a database by
passing a connection string via a Command or Recordset object. Anda juga dapat membuat
koneksi ke database dengan mengirimkan string koneksi melalui Command atau object
Recordset. However, this type of connection is only good for one specific, single query. Namun,
jenis koneksi yang hanya baik untuk satu query tertentu, tunggal.
ProgID PROGID
set objConnection=Server.CreateObject("ADODB.connection")
Properties
Property Description
ConnectionString Sets or returns the details used to create a connection to a data source
ConnectionTimeout Sets or returns the number of seconds to wait for a connection to open
Methods
Method Description
OpenSchema Returns schema information from the provider about the data source
RollbackTrans Cancels any changes in the current transaction and ends the transaction
Events
Note: You cannot handle events using VBScript or JScript (only Visual Basic, Visual C++, and
Visual J++ languages can handle events).
Event Description
Collections
Collection Description
The ADO Error object contains details about data access errors that have been generated during a
single operation. Objek Kesalahan ADO berisi rincian tentang kesalahan akses data yang telah
dihasilkan selama operasi tunggal.
ADO generates one Error object for each error. ADO menghasilkan satu objek Error untuk setiap
kesalahan. Each Error object contains details of the specific error, and are stored in the Errors
collection. Setiap object Error berisi rincian dari kesalahan tertentu, dan disimpan dalam koleksi
Kesalahan. To access the errors, you must refer to a specific connection. Untuk mengakses
kesalahan, Anda harus merujuk ke koneksi tertentu.
To loop through the Errors collection: Untuk loop melalui koleksi Kesalahan:
<%
for each objErr in objConn.Errors
response.write("<p>")
response.write("Description: ")
response.write(objErr.Description & "<br />")
response.write("Help context: ")
response.write(objErr.HelpContext & "<br />")
response.write("Help file: ")
response.write(objErr.HelpFile & "<br />")
response.write("Native error: ")
response.write(objErr.NativeError & "<br />")
response.write("Error number: ")
response.write(objErr.Number & "<br />")
response.write("Error source: ")
response.write(objErr.Source & "<br />")
response.write("SQL state: ")
response.write(objErr.SQLState & "<br />")
response.write("</p>")
next
%>
Syntax
objErr.property
Properties
Property Description
HelpContext Returns the context ID of a topic in the Microsoft Windows help system
HelpFile Returns the full path of the help file in the Microsoft Windows help
system
NativeError Returns an error code from the provider or the data source
Source Returns the name of the object or application that generated the error
SQLState Returns a 5-character SQL error code
The ADO Field object contains information about a column in a Recordset object. Objek ADO
Field berisi informasi tentang sebuah kolom dalam sebuah objek Recordset. There is one Field
object for each column in the Recordset. Ada satu objek Lapangan untuk setiap kolom dalam
Recordset.
ProgID PROGID
set objField=Server.CreateObject("ADODB.field")
Properties
Property Description
NumericScale Sets or returns the number of decimal places allowed for numeric values
in a Field object
GetChunk Returns all or a part of the contents of a large text or binary data Field
object
Collections
Collection Description
The ADO Parameter object provides information about a single parameter used in a stored
procedure or query. Objek ADO Parameter menyediakan informasi tentang satu parameter yang
digunakan dalam prosedur tersimpan atau query.
A Parameter object is added to the Parameters Collection when it is created. Sebuah objek
Parameter yang ditambahkan pada Koleksi Parameter ketika dibuat. The Parameters Collection is
associated with a specific Command object, which uses the Collection to pass parameters in and
out of stored procedures and queries. Koleksi Parameter dikaitkan dengan object Command
tertentu, yang menggunakan Koleksi untuk memberikan parameter dalam dan keluar dari
prosedur yang tersimpan dan pertanyaan.
Parameters can be used to create Parameterized Commands. Parameter dapat digunakan untuk
membuat parameter Perintah. These commands are (after they have been defined and stored)
using parameters to alter some details of the command before it is executed. Perintah-perintah ini
adalah (setelah mereka telah didefinisikan dan disimpan) menggunakan parameter untuk
mengubah beberapa detail dari perintah sebelum dieksekusi. For example, an SQL SELECT
statement could use a parameter to define the criteria of a WHERE clause. Sebagai contoh,
sebuah pernyataan SQL SELECT bisa menggunakan parameter untuk mendefinisikan kriteria
klausa WHERE.
There are four types of parameters: input parameters, output parameters, input/output parameters
and return parameters. Ada empat jenis parameter: parameter input, parameter output, / input
parameter keluaran dan parameter kembali.
Syntax Sintaksis
objectname.property
objectname.method
Properties
Property Description
NumericScale Sets or returns the number of digits stored to the right side of the
decimal point for a numeric value of a Parameter object
Methods
Method Description
The ADO Property object represents a dynamic characteristic of an ADO object that is defined
by the provider. Objek ADO Properti merupakan karakteristik dinamis dari sebuah objek ADO
yang didefinisikan oleh provider.
Each provider that talks with ADO has different ways of interacting with ADO. Setiap operator
yang berbicara dengan ADO memiliki cara yang berbeda berinteraksi dengan ADO. Therefore,
ADO needs to store information about the provider in some way. Oleh karena itu, ADO perlu
menyimpan informasi tentang penyedia dalam beberapa cara. The solution is that the provider
gives specific information (dynamic properties) to ADO. Solusinya adalah bahwa penyedia
memberikan informasi spesifik (properti dinamis) untuk ADO. ADO stores each provider
property in a Property object that is again stored in the Properties Collection. ADO setiap toko
properti penyedia dalam sebuah objek Harta Kekayaan yang lagi disimpan dalam Koleksi
Properties. The Collection is assigned to either a Command object, Connection object, Field
object, or a Recordset object. Koleksi ini ditugaskan untuk baik object Command, Connection
objek, objek Field, atau object Recordset.
ProgID PROGID
set objProperty=Server.CreateObject("ADODB.property")
Properties
Property Description
The ADO Record object is used to hold a row in a Recordset, a directory, or a file from a file
system. ADO Rekam obyek digunakan untuk menahan baris dalam sebuah Recordset, direktori,
atau file dari sebuah sistem berkas.
Only structured databases could be accessed by ADO in versions prior 2.5. Hanya database
terstruktur dapat diakses oleh ADO di versi sebelumnya 2.5. In a structured database, each table
has the exact same number of columns in each row, and each column is composed of the same
data type. Dalam database yang terstruktur, setiap tabel memiliki jumlah yang sama persis kolom
dalam setiap baris, dan kolom masing-masing terdiri dari tipe data yang sama.
The Record object allows access to data-sets where the number of columns and/or the data type
can be different from row to row. Objek Record memungkinkan akses ke data-set dimana jumlah
kolom dan / atau jenis data dapat berbeda dari baris ke baris.
Syntax Sintaksis
objectname.property
objectname.method
Properties
Property Description
Source Sets or returns the src parameter of the Open method of a Record
object
Methods
Method Description
GetChildren Returns a Recordset object where each row represents the files in
the directory
Collections
Collection Description
Count Returns the number of items in the fields collection. Starts at zero.
Example:
countfields=rec.Fields.Count
Item(named_item/number) Returns a specified item in the fields collection.
Example:
itemfields=rec.Fields.Item(1)
or
itemfields = rec.Fields.Item("Name")
GetRows GetRows
This example demonstrates how to use the GetRows method. Contoh ini menunjukkan
bagaimana menggunakan metode GetRows.
The ADO Recordset object is used to hold a set of records from a database table. ADO Recordset
obyek digunakan untuk menyimpan satu set catatan dari tabel database. A Recordset object
consist of records and columns (fields). Sebuah object Recordset terdiri dari catatan dan kolom
(field).
In ADO, this object is the most important and the one used most often to manipulate data from a
database. Dalam ADO, objek ini adalah yang paling penting dan yang paling sering digunakan
untuk memanipulasi data dari database.
ProgID PROGID
set objRecordset=Server.CreateObject("ADODB.recordset")
When you first open a Recordset, the current record pointer will point to the first record and the BOF
and EOF properties are False. If there are no records, the BOF and EOF property are True.
Recordset objects can support two types of updating:
Immediate updating - all changes are written immediately to the database once you call the
Update method.
Batch updating - the provider will cache multiple changes and then send them to the database
with the UpdateBatch method.
Dynamic cursor - Allows you to see additions, changes, and deletions by other users.
Keyset cursor - Like a dynamic cursor, except that you cannot see additions by other users, and
it prevents access to records that other users have deleted. Data changes by other users will still
be visible.
Static cursor - Provides a static copy of a recordset for you to use to find data or generate
reports. Additions, changes, or deletions by other users will not be visible. This is the only type
of cursor allowed when you open a client-side Recordset object.
Forward-only cursor - Allows you to only scroll forward through the Recordset. Additions,
changes, or deletions by other users will not be visible.
The cursor type can be set by the CursorType property or by the CursorType parameter in the
Open method.
Note: Not all providers support all methods or properties of the Recordset object.
Properties
Property Description
AbsolutePage Sets or returns a value that specifies the page number in the
Recordset object
AbsolutePosition Sets or returns a value that specifies the ordinal position of the
current record in the Recordset object
BOF Returns true if the current record position is before the first record,
otherwise false
DataMember Sets or returns the name of the data member that will be retrieved
from the object referenced by the DataSource property
EOF Returns true if the current record position is after the last record,
otherwise false
Index Sets or returns the name of the current index for a Recordset
object
LockType Sets or returns a value that specifies the type of locking when
editing a record in a Recordset
Status Returns the status of the current record with regard to batch
updates or other bulk operations
StayInSync Sets or returns whether the reference to the child records will
change when the parent record position changes
Methods
Method Description
NextRecordset Clears the current Recordset object and returns the next Recordset
object by looping through a series of commands
Resync Refreshes the data in the current Recordset from the original
database
Seek Searches the index of a Recordset to find a record that matches the
specified values
Events
Note: You cannot handle events using VBScript or JScript (only Visual Basic, Visual C++, and
Visual J++ languages can handle events).
Event Description
EndOfRecordset Triggered when you try to move to a record after the last record
MoveComplete Triggered after the current position in the Recordset has changed
Count Returns the number of items in the fields collection. Starts at zero.
Example:
countfields=rs.Fields.Count
Item(named_item/number) Returns a specified item in the fields collection.
Example:
itemfields=rs.Fields.Item(1)
or
itemfields=rs.Fields.Item("Name")
Example:
countprop=rs.Properties.Count
Item(named_item/number) Returns a specified item in the properties collection.
Example:
itemprop = rs.Properties.Item(1)
or
itemprop=rs.Properties.Item("Name")
The ADO Stream Object is used to read, write, and manage a stream of binary data or text. ADO
Object Stream digunakan untuk membaca, menulis, dan mengelola aliran data biner atau teks.
A Stream object can be obtained in three ways: Sebuah objek Stream dapat diperoleh dalam tiga
cara:
From a URL pointing to a document, a folder, or a Record object Dari sebuah URL yang
menunjuk ke dokumen, folder, atau benda Record
By instantiating a Stream object to store data for your application Dengan instantiate objek
Stream untuk menyimpan data untuk aplikasi Anda
By opening the default Stream object associated with a Record object Dengan membuka default
Stream objek yang terkait dengan benda Record
Syntax Sintaksis
objectname.property
objectname.method
Properties
Property Description
CharSet Sets or returns a value that specifies into which character set
the contents are to be translated. This property is only used
with text Stream objects (type is adTypeText)
Position Sets or returns the current position (in bytes) from the
beginning of a Stream object
SetEOS Sets the current position to be the end of the stream (EOS)
* In Oracle 8.0.x - decimal and int are equal to number and number(10). * Dalam Oracle 8.0.x -
desimal dan int yang sama dengan jumlah dan nomor (10).
This tutorial has taught you how to access data in a database from a web site. Tutorial ini
mengajarkan anda bagaimana untuk mengakses data dalam database dari sebuah situs web.
You have learned how to display data from a database on a web site, and how to edit, add and
delete the data with ADO. Anda telah belajar bagaimana untuk menampilkan data dari database
di situs web, dan bagaimana untuk mengedit, menambah dan menghapus data dengan ADO.
For more information on ADO, please look at our ADO examples . Untuk informasi lebih lanjut
tentang ADO, silahkan lihat di contoh ADO .
Now You Know ADO, What's Next? Sekarang Anda Tahu ADO, Apa Selanjutnya?
The next step is to learn SQL. Langkah berikutnya adalah untuk belajar SQL.
SQL is a standard computer language for accessing and manipulating database systems. SQL
adalah bahasa komputer standar untuk mengakses dan memanipulasi sistem database.
SQL statements are used to retrieve and update data in a database. pernyataan SQL digunakan
untuk mengambil dan mengupdate data dalam database. SQL works with database programs like
MS Access, DB2, Informix, MS SQL Server, Oracle, Sybase, and other database systems. SQL
bekerja dengan program database seperti MS Access, DB2, Informix, MS SQL Server, Oracle,
Sybase, dan sistem database lain.
If you want to learn more about SQL, please visit our SQL tutorial . Jika Anda ingin mempelajari
lebih lanjut tentang SQL, silahkan kunjungi tutorial SQL .
ADO Contoh
Tampilan
ASP Sumber:
<html> <html>
<body> <body>
<% <%
set conn=Server.CreateObject("ADODB.Connection") set conn = Server.CreateObject
("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb")) conn.Open (Server.Mappath ("/ db /
northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset") set rs = Server.CreateObject
("ADODB.Recordset")
rs.Open "Select * from Customers", conn rs.Open "Select * Pelanggan", conn
rs.close rs.close
conn.close conn.close
%> %>
Pelanggan = ALFKI
CompanyName = Alfreds Futterkiste CompanyName = Alfreds Futterkiste
ContactName = Maria Anders ContactName = Maria Anders
Address = Obere Str. Alamat = Str Obere. 57 57
City = Berlin Kota = Berlin
PostalCode = 12209 Kode Pos 12209 =
Country = Germany Negara = Jerman
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT Companyname, Contactname FROM Customers", conn
str=rs.GetString(,,"</td><td>","</td></tr><tr><td>"," ")
%>
<%
rs.close
conn.close
set rs = Nothing
set conn = Nothing
%>
</body>
</html>
Show example »
ASP Sumber:
<html>
<body> <body>
<% <%
set conn=Server.CreateObject("ADODB.Connection") set conn = Server.CreateObject
("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb")) conn.Open (Server.Mappath ("/ db /
northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset") set rs = Server.CreateObject
("ADODB.Recordset")
rs.Open "SELECT Companyname, Contactname FROM Customers", conn rs.Open "SELECT
CompanyName, Contactname DARI Pelanggan", conn
str=rs.GetString(,,"</td><td>","</td></tr><tr><td>"," ") str = (,,"</ rs.GetString td>
<td> ","</ td> </ tr> <tr> <td> "," ")
%> %>
<% <%
rs.close rs.close
conn.close conn.close
set rs = Nothing set rs = Tidak ada
set conn = Nothing set conn = Tidak ada
%> %>
ASP Sumber:
<html> <html>
<body> <body>
<% <%
set conn=Server.CreateObject("ADODB.Connection") set conn = Server.CreateObject
("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb")) conn.Open (Server.Mappath ("/ db /
northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset") set rs = Server.CreateObject
("ADODB.Recordset")
sql="SELECT Companyname, Contactname FROM Customers" sql = "SELECT
CompanyName, Contactname FROM Pelanggan"
rs.Open sql, conn rs.Open sql, conn
%> %>
CompanyName Contactname
Alfreds Futterkiste Maria Anders
Berglunds snabbköp Christina Berglund
Centro komersial Moctezuma Francisco Chang
Ernst Handel Roland Mendel
Inter FISSA fabrica. Salchichas SA Diego Roel
Galeria del gastrónomo Eduardo Saavedra
Pulau Trading Helen Bennett
Königlich Essen Philip Cramer
Laughing Bacchus Wine Cellars Yoshi Tannamuri
Magazzini Alimentari Riuniti Giovanni Rovelli
Utara / Selatan Simon Crowther
Paris spécialités Marie Bertrand
Ular berbisa Canyon Grocery Paula Wilson
Simons bistro Jytte Petersen
The Big Cheese Liz Nixon
Vaffeljernet Palle Ibsen
Wolski Zajazd Zbyszek Piestrzeniewicz
Add colors to the HTML table Tambahkan warna pada tabel HTML
ASP Sumber:
<html> <html>
<body> <body>
<% <%
set conn=Server.CreateObject("ADODB.Connection") set conn = Server.CreateObject
("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb")) conn.Open (Server.Mappath ("/ db /
northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset") set rs = Server.CreateObject
("ADODB.Recordset")
sql="SELECT Companyname, Contactname FROM Customers" sql = "SELECT
CompanyName, Contactname FROM Pelanggan"
rs.Open sql, conn rs.Open sql, conn
%> %>
CompanyName Contactname
Alfreds Futterkiste Maria Anders
Berglunds snabbköp Christina Berglund
Centro komersial Moctezuma Francisco Chang
Ernst Handel Roland Mendel
Inter FISSA fabrica. Salchichas SA Diego Roel
Galeria del gastrónomo Eduardo Saavedra
Pulau Trading Helen Bennett
Königlich Essen Philip Cramer
Laughing Bacchus Wine Cellars Yoshi Tannamuri
Magazzini Alimentari Riuniti Giovanni Rovelli
Utara / Selatan Simon Crowther
Paris spécialités Marie Bertrand
Ular berbisa Canyon Grocery Paula Wilson
Simons bistro Jytte Petersen
The Big Cheese Liz Nixon
Vaffeljernet Palle Ibsen
Wolski Zajazd Zbyszek Piestrzeniewicz
Queries Pertanyaan
ASP Sumber:
<html> <html>
<body> <body>
<% <%
set conn=Server.CreateObject("ADODB.Connection") set conn = Server.CreateObject
("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb")) conn.Open (Server.Mappath ("/ db /
northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset") set rs = Server.CreateObject
("ADODB.Recordset")
sql="SELECT Companyname, Contactname FROM Customers WHERE CompanyName LIKE 'A
%'" sql = "SELECT CompanyName, Contactname FROM Pelanggan WHERE CompanyName
LIKE 'A%'"
rs.Open sql, conn rs.Open sql, conn
%> %>
CompanyName Contactname
Alfreds Futterkiste Maria Anders
ASP Sumber:
<html>
<body> <body>
<% <%
set conn=Server.CreateObject("ADODB.Connection") set conn = Server.CreateObject
("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb")) conn.Open (Server.Mappath ("/ db /
northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset") set rs = Server.CreateObject
("ADODB.Recordset")
sql="SELECT Companyname, Contactname FROM Customers WHERE CompanyName>'E'"
sql = "SELECT CompanyName, Contactname FROM Pelanggan WHERE E 'CompanyName>'"
rs.Open sql, conn rs.Open sql, conn
%> %>
CompanyName Contactname
Ernst Handel Roland Mendel
Inter FISSA fabrica. Salchichas SA Diego Roel
Galeria del gastrónomo Eduardo Saavedra
Pulau Trading Helen Bennett
Königlich Essen Philip Cramer
Laughing Bacchus Wine Cellars Yoshi Tannamuri
Magazzini Alimentari Riuniti Giovanni Rovelli
Utara / Selatan Simon Crowther
Paris spécialités Marie Bertrand
Ular berbisa Canyon Grocery Paula Wilson
Simons bistro Jytte Petersen
The Big Cheese Liz Nixon
Vaffeljernet Palle Ibsen
Wolski Zajazd Zbyszek Piestrzeniewicz
ASP Sumber:
<html> <html>
<body> <body>
<% <%
set conn=Server.CreateObject("ADODB.Connection") set conn = Server.CreateObject
("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb")) conn.Open (Server.Mappath ("/ db /
northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset") set rs = Server.CreateObject
("ADODB.Recordset")
sql="SELECT Companyname, Contactname FROM Customers WHERE Country='Spain'" sql =
"SELECT CompanyName, Contactname FROM Pelanggan WHERE 'Spanyol Country ='"
rs.Open sql, conn rs.Open sql, conn
%> %>
CompanyName Contactname
Inter FISSA fabrica. Salchichas SA Diego Roel
Galeria del gastrónomo Eduardo Saavedra
ASP Sumber:
<html> <html>
<body> <body>
<% <%
set conn=Server.CreateObject("ADODB.Connection") set conn = Server.CreateObject
("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb")) conn.Open (Server.Mappath ("/ db /
northwind.mdb"))
%> %>
<% <%
if country<>"" then jika negara <> "" maka
sql="SELECT Companyname,Contactname,Country FROM Customers WHERE country='" &
country & "'" sql = "SELECT CompanyName, Contactname, Country FROM Pelanggan
WHERE country = '" & negara & "'"
set rs=Server.CreateObject("ADODB.Recordset") set rs = Server.CreateObject
("ADODB.Recordset")
rs.Open sql,conn rs.Open sql, conn
%> %>
<table width="100%" cellspacing="0" cellpadding="2" border="1"> <table width="100%"
cellpadding="2" cellspacing="0" border="1">
<tr> <tr>
<th>Companyname</th> <th> CompanyName </ th>
<th>Contactname</th> <th> Contactname </ th>
<th>Country</th> <th> Negara </ th>
</tr> </ Tr>
<% <%
do until rs.EOF lakukan sampai rs.EOF
response.write("<tr>") response.write ("<tr>")
response.write("<td>" & rs.fields("companyname") & "</td>") response.write ("<td>" &
rs.fields ("CompanyName") & "</ td>")
response.write("<td>" & rs.fields("contactname") & "</td>") response.write ("<td>" &
rs.fields ("contactname") & "</ td>")
response.write("<td>" & rs.fields("country") & "</td>") response.write ("<td>" & rs.fields
("negara") & "</ td>")
response.write("</tr>") response.write ("</ tr>")
rs.MoveNext rs.MoveNext
loop putaran
rs.close rs.close
conn.Close conn.Close
set rs=Nothing set rs = Tidak ada
set conn=Nothing%> set conn> Tidak ada% =
</table> </ Table>
<% end if %> <Akhir% jika%>
Sort Urutkan
Sort the records on a specified fieldname ascending Urutkan catatan pada fieldname tertentu naik
ASP Sumber:
<html>
<body> <body>
<% <%
set conn=Server.CreateObject("ADODB.Connection") set conn = Server.CreateObject
("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb")) conn.Open (Server.Mappath ("/ db /
northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset") set rs = Server.CreateObject
("ADODB.Recordset")
sql="SELECT Companyname, Contactname FROM Customers ORDER BY CompanyName" sql
= "SELECT CompanyName, Contactname DARI ORDER BY CompanyName Pelanggan"
rs.Open sql, conn rs.Open sql, conn
%> %>
Hasil Output:
CompanyName Contactname
Alfreds Futterkiste Maria Anders
Berglunds snabbköp Christina Berglund
Centro komersial Moctezuma Francisco Chang
Ernst Handel Roland Mendel
Inter FISSA fabrica. Salchichas SA Diego Roel
Galeria del gastrónomo Eduardo Saavedra
Pulau Trading Helen Bennett
Königlich Essen Philip Cramer
Laughing Bacchus Wine Cellars Yoshi Tannamuri
Magazzini Alimentari Riuniti Giovanni Rovelli
Utara / Selatan Simon Crowther
Paris spécialités Marie Bertrand
Ular berbisa Canyon Grocery Paula Wilson
Simons bistro Jytte Petersen
The Big Cheese Liz Nixon
Vaffeljernet Palle Ibsen
Wolski Zajazd Zbyszek Piestrzeniewicz
Sort the records on a specified fieldname descending Urutkan catatan pada fieldname tertentu
turun
ASP Sumber:
<html> <html>
<body> <body>
<% <%
set conn=Server.CreateObject("ADODB.Connection") set conn = Server.CreateObject
("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb")) conn.Open (Server.Mappath ("/ db /
northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset") set rs = Server.CreateObject
("ADODB.Recordset")
sql="SELECT Companyname, Contactname FROM Customers ORDER BY CompanyName
DESC" sql = "SELECT CompanyName, Contactname DARI ORDER BY DESC Pelanggan
CompanyName"
rs.Open sql, conn rs.Open sql, conn
%> %>
Hasil Output :
CompanyName Contactname
Wolski Zajazd Zbyszek Piestrzeniewicz
Vaffeljernet Palle Ibsen
The Big Cheese Liz Nixon
Simons bistro Jytte Petersen
Ular berbisa Canyon Grocery Paula Wilson
Paris spécialités Marie Bertrand
Utara / Selatan Simon Crowther
Magazzini Alimentari Riuniti Giovanni Rovelli
Laughing Bacchus Wine Cellars Yoshi Tannamuri
Königlich Essen Philip Cramer
Pulau Trading Helen Bennett
Galeria del gastrónomo Eduardo Saavedra
Inter FISSA fabrica. Salchichas SA Diego Roel
Ernst Handel Roland Mendel
Centro komersial Moctezuma Francisco Chang
Berglunds snabbköp Christina Berglund
Alfreds Futterkiste Maria Anders
Let the user choose what column to sort on Biarkan pengguna memilih apa kolom untuk
mengurutkan
ASP Sumber:
<html> <html>
<body> <body>
Perusahaan Kontak
Alfreds Futterkiste Maria Anders
Berglunds snabbköp Christina Berglund
Centro komersial Moctezuma Francisco Chang
Ernst Handel Roland Mendel
Inter FISSA fabrica. Salchichas SA Diego Roel
Galeria del gastrónomo Eduardo Saavedra
Pulau Trading Helen Bennett
Königlich Essen Philip Cramer
Laughing Bacchus Wine Cellars Yoshi Tannamuri
Magazzini Alimentari Riuniti Giovanni Rovelli
Utara / Selatan Simon Crowther
Paris spécialités Marie Bertrand
Ular berbisa Canyon Grocery Paula Wilson
Simons bistro Jytte Petersen
The Big Cheese Liz Nixon
Vaffeljernet Palle Ibsen
Wolski Zajazd Zbyszek Piestrzeniewicz
GetRows GetRows
ASP Sumber:
<html> <html>
<body> <body>
<% <%
set conn=Server.CreateObject("ADODB.Connection") set conn = Server.CreateObject
("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb")) conn.Open (Server.Mappath ("/ db /
northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset") set rs = Server.CreateObject
("ADODB.Recordset")
rs.Open "Select * from Customers", conn rs.Open "Select * Pelanggan", conn
'The first number indicates how many records to copy "Nomor pertama yang menunjukkan
berapa banyak catatan untuk menyalin
'The second number indicates what recordnumber to start on 'Angka kedua menunjukkan
apa yang recordnumber untuk memulai
p=rs.GetRows(2,0) p = rs.GetRows (2,0)
response.write("<p>This example returns the value of the first column in the first two
records:</p>") response.write ("<p> Contoh ini mengembalikan nilai kolom pertama dalam
catatan pertama dua: </ p>")
response.write(p(0,0)) response.write (p (0,0))
response.write("<br />") response.write ("/> <br")
response.write(p(0,1)) response.write (p (0,1))
response.write("<p>This example returns the value of the first three columns in the first
record:</p>") response.write ("<p> Contoh ini mengembalikan nilai kolom pertama tiga
dalam catatan pertama: </ p>")
response.write(p(0,0)) response.write (p (0,0))
response.write("<br />") response.write ("/> <br")
response.write(p(1,0)) response.write (p (1,0))
response.write("<br />") response.write ("/> <br")
response.write(p(2,0)) response.write (p (2,0))
rs.close rs.close
conn.close conn.close
%> %>
Contoh ini menampilkan nilai kolom pertama dalam dua catatan pertama:
ALFKI ALFKI
BERGS Bergs
This example returns the value of the first three columns in the first record: Contoh ini
mengembalikan nilai dari tiga kolom pertama dalam catatan pertama:
ALFKI ALFKI
Alfreds Futterkiste Alfreds Futterkiste
Maria Anders Maria Anders
GetString GetString
ASP Sumber:
<html>
<body> <body>
<% <%
set conn=Server.CreateObject("ADODB.Connection") set conn = Server.CreateObject
("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb")) conn.Open (Server.Mappath ("/ db /
northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset") set rs = Server.CreateObject
("ADODB.Recordset")
rs.Open "SELECT Companyname, Contactname FROM Customers", conn rs.Open "SELECT
CompanyName, Contactname DARI Pelanggan", conn
str=rs.GetString(,,"</td><td>","</td></tr><tr><td>"," ") str = (,,"</ rs.GetString td>
<td> ","</ td> </ tr> <tr> <td> "," ")
%> %>
<% <%
rs.close rs.close
conn.close conn.close
set rs = Nothing set rs = Tidak ada
set conn = Nothing set conn = Tidak ada
%> %>