dotConnect for MySQL Documentation
Devart.Data.MySql Namespace / MySqlLoader Class / SetValue Method / SetValue(Int32,Object) Method
Zero-based index of the column.
Column value.
Example

SetValue(Int32,Object) Method
Sets the value of the column at the specified ordinal.
Syntax
'Declaration
 
Public Overloads Overrides NotOverridable Sub SetValue( _
   ByVal i As Integer, _
   ByVal value As Object _
) 
 

Parameters

i
Zero-based index of the column.
value
Column value.
Remarks

Use SetValue(Int32,Object) method to set column with specific index in the current row to the value. To assign a column NULL value use Devart.Common.DbLoader.SetNull method instead.

The columns that you did not explicitly assign a value are considered to be NULL.

Example
This sample shows how to assign a value to a column referencing it by either name or index.
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();
  }
}
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