我正在尝试将一个列表项创建为另一个列表。我需要该列表每个项目都有另一个列表。我将字符串创建为一个循环的列表。下一个循环我需要将每个项目作为一个列表来根据范围插入数据。这个怎么做..??
我的代码:
List<string> l = new List<string>(s.Split(';'));
foreach (string item in l)
{
if (item.Contains("-"))
{
List<string> parts = new List<string>();
int min = Int32.Parse(parts[0]);
int max = Int32.Parse(parts[1]);
for (int m = min; m <= max; m++)
{
// add the value in i to the data
cmd = "insert into quickcom values('" + destination + "','" + codes + "','" + prefix + "','" + rate + "','" + level + "','" + m + "','" + effective_date + "','" + company_id + "')";
cmd = ReplaceSpecialCharacters(cmd);
MySqlCommand sqlCmd = new MySqlCommand(cmd, sqlCon);
var i = sqlCmd.ExecuteNonQuery();
cmd = "";
}
}
else
{
if (item.Contains(";"))
{
List<string> parts = new List<string>(s.Split(';'));
cmd = "insert into quickcom values('" + destination + "','" + codes + "','" + prefix + "','" + rate + "','" + level + "','" + s + "','" + effective_date + "','" + company_id + "')";
cmd = ReplaceSpecialCharacters(cmd);
MySqlCommand sqlCmd = new MySqlCommand(cmd, sqlCon);
var i = sqlCmd.ExecuteNonQuery();
cmd = "";
}
}
}
帮帮我... thnx