SlideShare a Scribd company logo
Introduction to ASPIntroduction to ASP
(Day 2)(Day 2)
JoniJoni
ATL - Bina NusantaraATL - Bina Nusantara
Agenda
• Database Processing using ADO in ASP
ADO - ActiveX Data Object
• A high-level data access API to access any data
source
• Relational database: Access, MSSQL, Oracle and any
ODBC compliant database
• Non-relational: e.g. Microsoft Index Server, Active
Directory Service
• Dual-interface COM interface
• Can be used in any scripting language (e.g. VBScript
in ASP) and compiled language (e.g. in Delphi).
ADO - ActiveX Data Object
• A high-level data access API to access any data
source
• Relational database: Access, MSSQL, Oracle and any
ODBC compliant database
• Non-relational: e.g. Microsoft Index Server, Active
Directory Service
• Dual-interface COM interface
• Can be used in any scripting language (e.g. VBScript
in ASP) and compiled language (e.g. in Delphi).
A Generic API...
• ADO provides a generic API for data
access. But the underlying data source
may not support some properties /
methods.
• Check the documentation of ADO and
the data provider.
Important ADO Objects
• Connection
• RecordSet
• Command
• How to report error
Making Connection
Dim conn
Dim ConnectionString
ConnectionString = "DSN=Pubs;UID=sa;PWD=pwd;"
Set conn =
Server.CreateObject(“ADODB.Connection”)
conn.Open ConnectionString
‘Now you can use conn to issue SQL command
‘...
conn.Close
Set conn = Nothing
Connection String (ODBC)
"DSN=Pubs;UID=sa;PWD=pwd;”"DSN=Pubs;UID=sa;PWD=pwd;”
“PROVIDER=MSDASQL; DRIVER={Microsoft Access
Driver (*.mdb)};DBQ=C:NWind.mdb; UID=admin;
PWD=;”
“PROVIDER=MSDASQL; DRIVER={Microsoft Access
Driver (*.mdb)};DBQ=C:NWind.mdb; UID=admin;
PWD=;”
“driver={SQL Server};server=srv;
uid=sa;pwd=pwd;database=pubs”
“driver={SQL Server};server=srv;
uid=sa;pwd=pwd;database=pubs”
Using DSN
DSNless, to MS SQL server
DSNless, to Access MDB
DSNless connection
is a bit faster
DSNless connection
is a bit faster
Connection String (OLE DB)
“Provider=Microsoft.Jet.OLEDB.3.51; Data
Source=c:inetpubwwwrootusers.mdb”
“Provider=SQLOLEDB; Data Source=myMachine;
Initial Catalog=pubs; User ID=sa;
Password=pwd”
OLE DB, to MS SQL server
OLE DB, to Access MDB
Direct OLE DB connection is faster than
ODBC connection in both connection
establishment and record retrieval.
Direct OLE DB connection is faster than
ODBC connection in both connection
establishment and record retrieval.
Executing SQL
You’ll need to use ADODB.Command ...
•If your update statement is executed many
times, you should consider using prepared
command for efficiency.
•If you call stored procedure with parameters,
use ADODB.Parameter with ADODB.Command
•If your update statement has BLOB objects, use
Property.AddChunk
You’ll need to use ADODB.Command ...
•If your update statement is executed many
times, you should consider using prepared
command for efficiency.
•If you call stored procedure with parameters,
use ADODB.Parameter with ADODB.Command
•If your update statement has BLOB objects, use
Property.AddChunk
‘assume conn is a live connection
strCommand = “UPDATE, INSERT or DELETE SQL”
conn.Execute strCommand, nRecordsAffected
Retrieving Data using RecordSet
‘assume conn is a live connection
strQuery = “select * from Employee”
Set rs =
Server.CreateObject(“ADODB.RecordSet”)
rs.Open strQuery, conn, cursorType, lockType
Do While Not rs.EOF
‘access the current record by
rs(“fieldname”)
‘or rs(fieldnum)
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
cursorType and lockType
are optional. The default
values are
adOpenForwardOnly and
adLockReadOnly
cursorType and lockType
are optional. The default
values are
adOpenForwardOnly and
adLockReadOnly
Retrieving Data using RecordSet
‘assume conn is a live connection
conn.BeginTrans
conn.Execute strCommand1
conn.Execute strCommand2
‘...
conn.CommitTrans
‘or conn.RollbackTrans
Demo

More Related Content

PDF
Introduction to Foxx by our community member Iskandar Soesman @ikandars
PDF
Deep Dive on ArangoDB
PDF
Experience with C++11 in ArangoDB
PDF
Rapid API Development ArangoDB Foxx
PDF
Asp.Net 3.5 Part 2
PPTX
Intro to RavenDB
PDF
Introduction to ArangoDB (nosql matters Barcelona 2012)
PDF
Building a spa_in_30min
Introduction to Foxx by our community member Iskandar Soesman @ikandars
Deep Dive on ArangoDB
Experience with C++11 in ArangoDB
Rapid API Development ArangoDB Foxx
Asp.Net 3.5 Part 2
Intro to RavenDB
Introduction to ArangoDB (nosql matters Barcelona 2012)
Building a spa_in_30min

What's hot (20)

PPTX
Javascript on Server-Side
PPTX
RavenDB Presentation
PDF
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...
ODP
PDF
Microservice-based software architecture
PPTX
Understanding LINQ in C#
PPTX
RavenDB - Indexes Deep Dive
PPT
Document Databases & RavenDB
PPTX
Azure DocumentDB 101
PDF
PDF
Extensible Database APIs and their role in Software Architecture
PPTX
RavenDB Overview
PPTX
Presentation: mongo db & elasticsearch & membase
PPTX
NoSQL Database in .NET Apps
PDF
Why we love ArangoDB. The hunt for the right NosQL Database
PDF
Lecture #5 Introduction to rails
PDF
Introduction to Rails by Evgeniy Hinyuk
PPTX
Introduction to RavenDB
Javascript on Server-Side
RavenDB Presentation
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...
Microservice-based software architecture
Understanding LINQ in C#
RavenDB - Indexes Deep Dive
Document Databases & RavenDB
Azure DocumentDB 101
Extensible Database APIs and their role in Software Architecture
RavenDB Overview
Presentation: mongo db & elasticsearch & membase
NoSQL Database in .NET Apps
Why we love ArangoDB. The hunt for the right NosQL Database
Lecture #5 Introduction to rails
Introduction to Rails by Evgeniy Hinyuk
Introduction to RavenDB
Ad

Similar to Asp #2 (20)

PPT
PPTX
ADO.NET -database connection
PPT
vishual basic data base Pankaj
PPTX
Data base connectivity and flex grid in vb
PDF
Oracle to vb 6.0 connectivity
PPTX
Ado object
PPTX
76.pptx ajx ppt file for univercity of granted
PPS
VISUAL BASIC .net data accesss vii
PPTX
Ado .net
PPTX
PPT
ASP.NET Session 11 12
PPT
Chapter 4 event it theory programming.pptx
PPT
Marmagna desai
PDF
Db connection to qtp
PPT
Data management with ado
PPT
Sql server classes in mumbai
PPTX
Is2215 lecture7 lecturer_ado_intro
PDF
PPT
PI-RDBMS.ppt
ADO.NET -database connection
vishual basic data base Pankaj
Data base connectivity and flex grid in vb
Oracle to vb 6.0 connectivity
Ado object
76.pptx ajx ppt file for univercity of granted
VISUAL BASIC .net data accesss vii
Ado .net
ASP.NET Session 11 12
Chapter 4 event it theory programming.pptx
Marmagna desai
Db connection to qtp
Data management with ado
Sql server classes in mumbai
Is2215 lecture7 lecturer_ado_intro
PI-RDBMS.ppt
Ad

More from Joni (13)

PPTX
ASP.NET Core の ​ パフォーマンスを支える ​ I/O Pipeline と Channel
PPTX
.NET Framework で ​C# 8って使える? ​YESとNO!
PPTX
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築
PPTX
Fiddler 使ってますか?
PPTX
Fukuoka.NET Conf 2018: 挑み続ける!Dockerコンテナによる ASP.NET Core アプリケーション開発事例
PPTX
ASP.NET パフォーマンス改善
PPT
Introduction to .NET
PPT
Tips and Tricks of Developing .NET Application
PPT
Introduction to Html
PPT
C#
PPT
Asp #1
PPT
Introduction to ASP.NET
PPTX
ASP.NET MVCはNullReferenceExceptionを潰している件
ASP.NET Core の ​ パフォーマンスを支える ​ I/O Pipeline と Channel
.NET Framework で ​C# 8って使える? ​YESとNO!
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築
Fiddler 使ってますか?
Fukuoka.NET Conf 2018: 挑み続ける!Dockerコンテナによる ASP.NET Core アプリケーション開発事例
ASP.NET パフォーマンス改善
Introduction to .NET
Tips and Tricks of Developing .NET Application
Introduction to Html
C#
Asp #1
Introduction to ASP.NET
ASP.NET MVCはNullReferenceExceptionを潰している件

Recently uploaded (20)

PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
history of c programming in notes for students .pptx
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
ISO 45001 Occupational Health and Safety Management System
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
medical staffing services at VALiNTRY
PPTX
Essential Infomation Tech presentation.pptx
PPTX
ai tools demonstartion for schools and inter college
PDF
Digital Strategies for Manufacturing Companies
PPT
JAVA ppt tutorial basics to learn java programming
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Introduction to Artificial Intelligence
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
history of c programming in notes for students .pptx
Operating system designcfffgfgggggggvggggggggg
VVF-Customer-Presentation2025-Ver1.9.pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PTS Company Brochure 2025 (1).pdf.......
Upgrade and Innovation Strategies for SAP ERP Customers
ISO 45001 Occupational Health and Safety Management System
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
How to Migrate SBCGlobal Email to Yahoo Easily
medical staffing services at VALiNTRY
Essential Infomation Tech presentation.pptx
ai tools demonstartion for schools and inter college
Digital Strategies for Manufacturing Companies
JAVA ppt tutorial basics to learn java programming
Odoo POS Development Services by CandidRoot Solutions
Introduction to Artificial Intelligence
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Which alternative to Crystal Reports is best for small or large businesses.pdf

Asp #2

  • 1. Introduction to ASPIntroduction to ASP (Day 2)(Day 2) JoniJoni ATL - Bina NusantaraATL - Bina Nusantara
  • 3. ADO - ActiveX Data Object • A high-level data access API to access any data source • Relational database: Access, MSSQL, Oracle and any ODBC compliant database • Non-relational: e.g. Microsoft Index Server, Active Directory Service • Dual-interface COM interface • Can be used in any scripting language (e.g. VBScript in ASP) and compiled language (e.g. in Delphi).
  • 4. ADO - ActiveX Data Object • A high-level data access API to access any data source • Relational database: Access, MSSQL, Oracle and any ODBC compliant database • Non-relational: e.g. Microsoft Index Server, Active Directory Service • Dual-interface COM interface • Can be used in any scripting language (e.g. VBScript in ASP) and compiled language (e.g. in Delphi).
  • 5. A Generic API... • ADO provides a generic API for data access. But the underlying data source may not support some properties / methods. • Check the documentation of ADO and the data provider.
  • 6. Important ADO Objects • Connection • RecordSet • Command • How to report error
  • 7. Making Connection Dim conn Dim ConnectionString ConnectionString = "DSN=Pubs;UID=sa;PWD=pwd;" Set conn = Server.CreateObject(“ADODB.Connection”) conn.Open ConnectionString ‘Now you can use conn to issue SQL command ‘... conn.Close Set conn = Nothing
  • 8. Connection String (ODBC) "DSN=Pubs;UID=sa;PWD=pwd;”"DSN=Pubs;UID=sa;PWD=pwd;” “PROVIDER=MSDASQL; DRIVER={Microsoft Access Driver (*.mdb)};DBQ=C:NWind.mdb; UID=admin; PWD=;” “PROVIDER=MSDASQL; DRIVER={Microsoft Access Driver (*.mdb)};DBQ=C:NWind.mdb; UID=admin; PWD=;” “driver={SQL Server};server=srv; uid=sa;pwd=pwd;database=pubs” “driver={SQL Server};server=srv; uid=sa;pwd=pwd;database=pubs” Using DSN DSNless, to MS SQL server DSNless, to Access MDB DSNless connection is a bit faster DSNless connection is a bit faster
  • 9. Connection String (OLE DB) “Provider=Microsoft.Jet.OLEDB.3.51; Data Source=c:inetpubwwwrootusers.mdb” “Provider=SQLOLEDB; Data Source=myMachine; Initial Catalog=pubs; User ID=sa; Password=pwd” OLE DB, to MS SQL server OLE DB, to Access MDB Direct OLE DB connection is faster than ODBC connection in both connection establishment and record retrieval. Direct OLE DB connection is faster than ODBC connection in both connection establishment and record retrieval.
  • 10. Executing SQL You’ll need to use ADODB.Command ... •If your update statement is executed many times, you should consider using prepared command for efficiency. •If you call stored procedure with parameters, use ADODB.Parameter with ADODB.Command •If your update statement has BLOB objects, use Property.AddChunk You’ll need to use ADODB.Command ... •If your update statement is executed many times, you should consider using prepared command for efficiency. •If you call stored procedure with parameters, use ADODB.Parameter with ADODB.Command •If your update statement has BLOB objects, use Property.AddChunk ‘assume conn is a live connection strCommand = “UPDATE, INSERT or DELETE SQL” conn.Execute strCommand, nRecordsAffected
  • 11. Retrieving Data using RecordSet ‘assume conn is a live connection strQuery = “select * from Employee” Set rs = Server.CreateObject(“ADODB.RecordSet”) rs.Open strQuery, conn, cursorType, lockType Do While Not rs.EOF ‘access the current record by rs(“fieldname”) ‘or rs(fieldnum) rs.MoveNext Loop rs.Close Set rs = Nothing cursorType and lockType are optional. The default values are adOpenForwardOnly and adLockReadOnly cursorType and lockType are optional. The default values are adOpenForwardOnly and adLockReadOnly
  • 12. Retrieving Data using RecordSet ‘assume conn is a live connection conn.BeginTrans conn.Execute strCommand1 conn.Execute strCommand2 ‘... conn.CommitTrans ‘or conn.RollbackTrans
  • 13. Demo