当我尝试将数据从CSV文件插入MYSQL数据库时,我想知道如何解决这种错误。以下是我的代码:
while (null != (sLine = __reader.ReadLine()))
{
while (rexRunOnLine.IsMatch(sLine) && null != (sNextLine = __reader.ReadLine()))
{
sLine += "\n" + sNextLine;
__rowno++;
string[] values = rexCsvSplitter.Split(sLine);
billOfMaterials.Allotment_code = values[0];
billOfMaterials.category_name = values[1];
billOfMaterials.activity = values[2];
billOfMaterials.quantity = values[3];
billOfMaterials.end_unit_quantity = values[4];
billOfMaterials.unit = values[5];
billOfMaterials.description = values[6];
billOfMaterials.unit_cost = values[7];
billOfMaterials.regular_labor_cost = values[8];
billOfMaterials.end_unit_labor_cost = values[9];
billOfMaterials.type = values[10];
billOfMaterials.batch = int.Parse(values[11]);
billOfMaterials.AddBillOfMaterials();
yield return values;
}
__reader.Close();
}
这是我遇到的错误: