Low cost ecommerce web development India flash website design
After setting the mode, you must set the Connection object's
ConnectionString property. Although you must set this property each time
you open a new Connection object, you should define the connection string
(or strings) in your application's global.asa file as an application-level or
session-level variable. There are at least three reasons to define the connection
string in the global.asa file; it means you only have one place to check for
connection string problems, you can change the connection from one database
to another with minimal code changes during development, and you can copy
or move your application from one server to another very quickly.
The ConnectionString property is both simple and complicated. It has
several parts, all of which are optional, depending on which type of
connection string you're using, but typically, you specify the following:
§ Provider name
§ Name of the database server
§ Name of the database you want to use
§ User ID (UID) with which to connect
§ Password (PWD) for that user ID.
59
You separate the parts of the connection string with semicolons. For example,
at the simplest level, you can use an Open Database Connectivity (ODBC)
Data Source Name (DSN), a user ID, and password to connect to your
database. A DSN already contains the provider, the database server, and the
database name, so you don't have to specify those again.
For example:
Dim
Conn.Mode = adModeReadWrite
Conn.ConnectionString = “DSN=myDSN;UID=manas;PWD=manas;"
Unfortunately, that's not the best method. By default, ODBC DSNs use the
MSDASQL provider, but the JET OLEDB provider is faster and provides
more functionality. Use this type of connection string instead.
Dim
ConnStr= "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" +
Server.MapPath(Path2DB)
Conn.Mode = adModeReadWrite
Conn.ConnectionString = ConnStr
The connection string contains the provider name, the name of the server (in
this case, and the path to the MDB file. We use the Server.MapPath function
to translate the virtual path to the actual path on the server's disk. For
example, a database at the location
http://www.manastungare.com/users.mdb
can actually be the file
E:\Web\Databases\users.mdb
Server.MapPath translates the first address to the second (which is what is
needed by the ADODB.Connection object.)
You must set most of the Connection object's properties before opening the
connection. If you later want to change a property, close the connection,
change the property value, and then reopen the connection.
To open a connection, use the Open method of the Connection object.
Conn.Open
If the Open method executes without errors, you have a working connection
to the database.
60
All the procedures so far can be simplified with an alternate syntax. The Open
method accepts up to four optional arguments: a ConnectionString, a user ID,
a password, and the Options argument consisting of a ConnectOptionEnum
constant.
Conn.Open ConnStr, "manas", "manas", adAsyncConnect
You can specify more than one value for the options by adding the constants
together.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73