![background image](http://html1.mh-extra.com/html/oracle/5-0/5-0_reference-manual_16461961928.webp)
Connector/Net Programming
1908
Next
Catch ex As MySqlException
MessageBox.Show("Error " & ex.Number & " has occurred: " & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
C# Example
MySql.Data.MySqlClient.MySqlConnection conn;
MySql.Data.MySqlClient.MySqlCommand cmd;
conn = new MySql.Data.MySqlClient.MySqlConnection();
cmd = new MySql.Data.MySqlClient.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 (int i=1; i <= 1000; i++)
{
cmd.Parameters["@number"].Value = i;
cmd.Parameters["@text"].Value = "A string value";
cmd.ExecuteNonQuery();
}
}
catch (MySql.Data.MySqlClient.MySqlException ex)
{
MessageBox.Show("Error " + ex. " has occurred: " + ex.Message,
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
20.2.5.9. Accessing Stored Procedures with Connector/Net
MySQL server version 5 and up supports stored procedures with the SQL 2003 stored procedure
syntax.
A stored procedure is a set of SQL statements that is stored in the server. Clients make a single call to
the stored procedure, passing parameters that can influence the procedure logic and query conditions,
rather than issuing individual hardcoded SQL statements.
Stored procedures can be particularly useful in situations such as the following:
• Stored procedures can act as an API or abstraction layer, allowing multiple client applications to
perform the same database operations. The applications can be written in different languages and
run on different platforms. The applications do not need to hardcode table and column names,
complicated queries, and so on. When you extend and optimize the queries in a stored procedure, all
the applications that call the procedure automatically receive the benefits.
• When security is paramount, stored procedures keep applications from directly manipulating
tables, or even knowing details such as table and column names. Banks, for example, use stored
procedures for all common operations. This provides a consistent and secure environment, and
procedures can ensure that each operation is properly logged. In such a setup, applications and
users would not get any access to the database tables directly, but can only execute specific stored
procedures.
Connector/Net supports the calling of stored procedures through the
MySqlCommand
object. Data can
be passed in and out of a MySQL stored procedure through use of the
MySqlCommand.Parameters
collection.
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...