Connection Property (MySqlLoader)
Gets or sets the
MySqlConnection used by this instance of the
MySqlLoader.
Property Value
The connection to a data source. The default value is a null reference.
The following example creates a
MySqlLoader, then populates Columns collection from table description, loads data, flushes the buffer and dispose internal
MySqlLoader structures.
public void LoadData(MySqlConnection myConnection)
{
myConnection.Open();
myConnection.Database = "Test";
MySqlLoader loader = new MySqlLoader();
loader.Connection = myConnection;
loader.TableName = "load_table";
try
{
loader.CreateColumns();
loader.Open();
for (int i = 1; i <= 10000; i++)
{
loader.SetValue("id", i);
loader.SetValue("char_field", "test string");
loader.SetValue("date_field", DateTime.Now);
loader.NextRow();
}
loader.Close();
}
finally
{
myConnection.Close();
}
}
Public Sub LoadData(ByVal myConnection As MySqlConnection)
myConnection.Open()
myConnection.Database = "Test"
Dim loader As MySqlLoader
loader = New MySqlLoader
loader.Connection = myConnection
loader.TableName = "load_table"
Try
loader.CreateColumns()
loader.Open()
Dim i As Integer
For i = 1 To 10000
loader.SetValue("id", i)
loader.SetValue("char_field", "test string")
loader.SetValue("date_field", DateTime.Now)
loader.NextRow()
Next i
loader.Close()
Finally
myConnection.Close()
End Try
End Sub