Documentos de Académico
Documentos de Profesional
Documentos de Cultura
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:
<%
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.
<%
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.
An ODBC Connection to an MS Access Database
Here is how to create a connection to a MS Access Database:
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.
Connection Object
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.
If you want to access a database multiple times, you should establish a connection using the
Connection object. You can also make a connection to a database by passing a connection string
via a Command or Recordset object. However, this type of connection is only good for one
specific, single query.
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
ADO ADO.Net
ADO is base on COM : Component Object Modelling based. ADO.Net is based on CLR : Common Language Runtimebased.
ADO stores data in binary format. ADO.Net stores data in XML format i.e. parsing of data.
ADO can’t be integrated with XML because ADO have limited access ADO.Net can be integrated with XML as having robust support of
of XML. XML.
In ADO, data is provided by RecordSet. In ADO.Net data is provided by DataSet or DataAdapter.
ADO is connection oriented means it requires continuous active ADO.Net is disconnected, does not need continuous connection.
connection.
ADO gives rows as single table view, it scans sequentially the rows ADO.Net gives rows as collections so you can access any record and
using MoveNext method. also can go through a table via loop.
In ADO, You can create only Client side cursor. In ADO.Net, You can create both Client & Server side cursor.
Using a single connection instance, ADO can not handle multiple Using a single connection instance, ADO.Net can handle multiple
transactions. transactions.
System.Data and its five supporting namespaces define the ADO.NET functionality. In this
article, you'll take a brief look of these namespace. These namespaces reside in the
System.Data.dll assembly. Figure shows the contents of this assembly in the IL DASM utility.
Figure: The system. Data assembly contents in the IL DASM utility
The System.Data namespace is the core namespace of ADO .NET. It consists of the base
classes for the ADO.NET architecture. All data providers use these classes. It defines classes
that represent table, columns, row, and datasets some common classes from this namespace
DataView, DataViewManager DataSet, DataTable, DataRow, DataColumn, and DataRelation.
To use these classes in your applications, you need to add a reference to the System.Data
namespace.
NOTE: All classes in the .NET base library are derived from the Object class and represent a
type. Some authors and documentation also use word type for a .NET framework class.
The System.Data.Common. namespace defines common classes. These classes are base
classes for concrete data provider classes. These classes are shared among all data providers.
DBConnection, DataAdapter, DBDataAdapter, DataColumnMapping and DataTableMapping are
some of the classed defined in this namespace. To use these classes in your application, you
need to add a reference to the System.Data.Common namespace in your application.
The System.Data.OleDb namespace defines classes to work with OLE-DB data sources
using.NET OleDb data providers. To work with an OLE-DB data source, you must have an OLE-
DB provider for that data source. Each data provider component has a class corresponding to it.
These classes start with OleDb followed by the component. For example, OleDbConnection
class represents a Connection object. Some of the common classes of this namespace are
OleDbDataAdapter, OleDbDataReader, OleDbCommand, OleDbCommandBuilder OleDbError,
OleDbParameter, OleDbPermission, and OleDbTransaction. To use these classes in your
application, your need to add a reference to the System.Data.OleDb namespace in your
application.
The last namespace, System.DataSqlTypes, providers a group classes representing the specific
types found in SQL server. Some of these classes are SqlBinary SqlMoney, SqlString,
SqlDouble, SqlDateTime, and SqlNumeric.