Oracle 5.0 Reference Manual page 1927

Table of Contents

Advertisement

This feature exists with Connector/Net versions 6.4 and above.
Table caching is a feature that can be used to cache slow-changing datasets on the client side. This is
useful for applications that are designed to use readers, but still want to minimize trips to the server for
slow-changing tables.
This feature is transparent to the application, and is disabled by default.
Configuration
• To enable table caching, add
• Optionally, specify the
the number of seconds a table is cached before the cached data is discarded. The default value is
60.
• You can turn caching on and off and set caching options at runtime, on a per-command basis.
20.2.5.8. Using the Connector/Net with Prepared Statements
As of MySQL 4.1, it is possible to use prepared statements with Connector/Net. Use of prepared
statements can provide significant performance improvements on queries that are executed more than
once.
Prepared execution is faster than direct execution for statements executed more than once, primarily
because the query is parsed only once. In the case of direct execution, the query is parsed every time
it is executed. Prepared execution also can provide a reduction of network traffic because for each
execution of the prepared statement, it is necessary only to send the data for the parameters.
Another advantage of prepared statements is that it uses a binary protocol that makes data transfer
between client and server more efficient.
20.2.5.8.1. Preparing Statements in Connector/Net
To prepare a statement, create a command object and set the
After entering your statement, call the
statement is prepared, add parameters for each of the dynamic elements in the query.
After you enter your query and enter parameters, execute the statement using the
.ExecuteNonQuery(), .ExecuteScalar(), or
For subsequent executions, you need only modify the values of the parameters and call the execute
method again, there is no need to set the
Visual Basic Example
Dim conn As New MySqlConnection
Dim cmd As New MySqlCommand
conn.ConnectionString = strConnection
Try
conn.Open()
cmd.Connection = conn
cmd.CommandText = "INSERT INTO myTable VALUES(NULL, @number, @text)"
cmd.Prepare()
cmd.Parameters.AddWithValue("@number", 1)
cmd.Parameters.AddWithValue("@text", "One")
For i = 1 To 1000
cmd.Parameters("@number").Value = i
cmd.Parameters("@text").Value = "A string value"
cmd.ExecuteNonQuery()
Connector/Net Programming
'table cache = true'
'Default Table Cache Age'
.Prepare
.CommandText
1907
to the connection string.
connection string option, which represents
.CommandText
method of the
MySqlCommand
methods.
.ExecuteReader
property or redefine the parameters.
property to your query.
object. After the

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents