Class MySqlScript
Provides a class capable of executing a SQL script containing multiple SQL statements including CREATE PROCEDURE statements that require changing the delimiter
Namespace: MySql.Data.MySqlClient
Assembly: MySql.Data.dll
Version: 9.0.0
Syntax
public class MySqlScript
Constructors
MySqlScript()
Initializes a new instance of the MySqlScript class.
Declaration
public MySqlScript()
MySqlScript(MySqlConnection)
Initializes a new instance of the MySqlScript class.
Declaration
public MySqlScript(MySqlConnection connection)
Parameters
Type | Name | Description |
---|---|---|
MySqlConnection | connection | The connection. |
MySqlScript(MySqlConnection, String)
Initializes a new instance of the MySqlScript class.
Declaration
public MySqlScript(MySqlConnection connection, string query)
Parameters
Type | Name | Description |
---|---|---|
MySqlConnection | connection | The connection. |
String | query | The query. |
MySqlScript(String)
Initializes a new instance of the MySqlScript class.
Declaration
public MySqlScript(string query)
Parameters
Type | Name | Description |
---|---|---|
String | query | The query. |
Properties
Connection
Gets or sets the connection.
Declaration
public MySqlConnection Connection { get; set; }
Property Value
Type | Description |
---|---|
MySqlConnection | The connection. |
Delimiter
Gets or sets the delimiter.
Declaration
public string Delimiter { get; set; }
Property Value
Type | Description |
---|---|
String | The delimiter. |
Query
Gets or sets the query.
Declaration
public string Query { get; set; }
Property Value
Type | Description |
---|---|
String | The query. |
Methods
Execute()
Executes this instance.
Declaration
public int Execute()
Returns
Type | Description |
---|---|
Int32 | The number of statements executed as part of the script. |
ExecuteAsync()
Initiates the asynchronous execution of SQL statements.
Declaration
public Task<int> ExecuteAsync()
Returns
Type | Description |
---|---|
Task<Int32> | The number of statements executed as part of the script inside. |
ExecuteAsync(CancellationToken)
Initiates the asynchronous execution of SQL statements.
Declaration
public Task<int> ExecuteAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
Task<Int32> | The number of statements executed as part of the script inside. |
Events
Error
Handles the event raised whenever an error is raised by the execution of a script.
Declaration
public event MySqlScriptErrorEventHandler Error
Event Type
Type | Description |
---|---|
MySqlScriptErrorEventHandler |
ScriptCompleted
Handles the event raised whenever a script execution is finished.
Declaration
public event EventHandler ScriptCompleted
Event Type
Type | Description |
---|---|
System.EventHandler |
StatementExecuted
Handles the event raised whenever a statement is executed.
Declaration
public event MySqlStatementExecutedEventHandler StatementExecuted
Event Type
Type | Description |
---|---|
MySqlStatementExecutedEventHandler |