Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm inserting data into MySQL database with mysqlbulkloader. it works but the problem is it inserts into the identity column which is auto incremented. Is there anyway I can map the columns or skip the identity column.
Thank you

What I have tried:

Using con1 As New MySqlConnection(constr)
Dim bl As New MySqlBulkLoader(con1)
bl.TableName = "tblquestions"
bl.FieldTerminator = (",")
bl.LineTerminator = "\r\n"
bl.FileName = path
bl.NumberOfLinesToSkip = 1
bl.Load()
End Using
Posted
Updated 24-May-16 18:38pm

1 solution

I dont know what it looks like from a VB.Net perspective, but in c# I would do :-

Columns = { "Field1", "Field2", "Field3" }

as in

C#
using (var conn = new MySqlConnection(connectionString))
{
    var bl = new MySqlBulkLoader(conn)
    {
        TableName = "tblquestions",
        Timeout = 600,
        FieldTerminator = ",",
        LineTerminator = "\r\n",
        FileName = path,
        NumberOfLinesToSkip = 1,
        Columns = { "Field1", "Field2", "Field3" }
    };
    var numberOfInsertedRows = bl.Load();
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900