Low cost ecommerce web development India flash website design

The Connection.Execute Method

There are three ways to obtain data from a database using ADO. All of them

require a connection. The simplest way is to use the Execute method of the

Connection object.

The Execute method accepts three arguments

§ An SQL statement or query, table, view, or stored procedure name called

the CommandText argument

§ A variable called RecordsAffected that will contain the number of records

affected by the statement or query after the Execute method completes

§ And a CommandTypeEnum constant called Options that tells the database

what type of statement or query you want to run, and whether to return a

Recordset object.

Connection objects can open tables directly, and can execute SQL in either

pre-compiled form (called stored procedures) or dynamically by interpreting

and executing the SQL statement at runtime. All these types of requests return

records. The returned records are called result sets, and ADO wraps the

resulting rows in a Recordset object.

The return value of the Execute method, by default, is a Recordset object that

contains the result of the statement or query. You can control whether the

Execute method returns a Recordset object by adding the

adExecuteNoRecords constant to the Options constant. If you're running a

SELECT statement, you generally need the resulting Recordset object; but

when you're running an INSERT or UPDATE query, you usually don't need

any records returned.

Managing Transactions with a Connection Object

When you submit a command that changes data to SQL Server, such as an

UPDATE, INSERT, or DELETE query, it always treats the statement as a

transaction. If the statement fails, all operations in the statement fail-

However, you often need to execute one or more statements as a transaction.

To do that, you must wrap the statements in a high-level transaction yourself.

61

You manage transactions with the Connection object's BeginTrans,

CommitTrans, and RollbackTrans methods.

freelance web designer India web development

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