本文介绍了Mysqlbulkloader列映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用mysqlbulkloader将数据插入MySQL数据库。它的工作原理但问题是它插入到自动递增的标识列中。无论如何我可以映射列或跳过标识列。

谢谢



我尝试过:



使用con1作为新的MySqlConnection(constr)

Dim bl作为新的MySqlBulkLoader(con1)

bl.TableName =tblquestions

bl.FieldTerminator =(,)

bl.LineTerminator =\\\\ n

bl.FileName = path

bl.NumberOfLinesToSkip = 1

bl.Load()

结束使用

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

推荐答案

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();
}


这篇关于Mysqlbulkloader列映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 16:57