The table remains locked untill you call Close method, or lock another table, or close the thread that issued LOCK operation.
Note that when you have locked a table, you can not access any other table from the same thread.
public void LoadData(MySqlConnection myConnection) { myConnection.Open(); myConnection.Database = "Test"; MySqlLoader loader = new MySqlLoader(); loader.Connection = myConnection; loader.TableName = "load_table"; loader.Lock = true; 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" loader.Lock = True 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
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2