See Also

MySqlLoader Members  | CoreLab.MySql Namespace  | MySqlLoaderColumn Class  | MySqlLoaderColumnCollection Class

 

Language

Visual Basic

C#

Show All

See AlsoRequirementsLanguagesCoreLab.MySqlSend comments on this topic.

MySqlLoader Class

Serves to load external data into the MySQL database.

For a list of all members of this type, see MySqlLoader members.

Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         CoreLab.Common.DbLoader
            CoreLab.MySql.MySqlLoader

Syntax

[Visual Basic]
Public NotInheritable Class MySqlLoader    Inherits DbLoader    Implements IComponent, IDisposable 
[C#]
public sealed class MySqlLoader : DbLoader, IComponent, IDisposable 

Remarks

MySqlLoader work is based on generation of INSERT statements that insert data by several rows at the same time. To specify the name of loading table set TableName property. Use Columns property to access individual columns. Performance of MySqlLoader greatly exceeds performance of other data access components.

Note: This class is available with MyDirect .NET Professional edition only.

Example

The following example creates a MySqlLoader, then populates Columns collection from table description, loads data, flushes the buffer, and disposes internal MySqlLoader structures. The MySqlLoader requires open connection.

[C#] 

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(1, "test string"); 
      loader.SetValue("date_field", DateTime.Now); 
      loader.NextRow(); 
    } 
    loader.Close(); 
  } 
  finally 
  { 
    myConnection.Close(); 
  } 
}

[Visual Basic] 

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(1, "test string")
      loader.SetValue("date_field", DateTime.Now)
      loader.NextRow()
    Next i
    loader.Close()
  Finally
    myConnection.Close()
  End Try
End Sub

 

See Also

MySqlLoader Members  | CoreLab.MySql Namespace  | MySqlLoaderColumn Class  | MySqlLoaderColumnCollection Class

 

 


© 2002 - 2008 Devart. All Rights Reserved.