我无法增加列表项属性的索引。这是代码。
Dim i As Integer = 0
For x As Integer = 1 To list.Count / 19
database.ExecuteCommand("INSERT INTO Contacts VALUES ('" + _
list.Item(i) + "', '" + _
list.Item(++i) + "', '" + _
list.Item(++i) + "', '" + _
list.Item(++i) + "', '" + _
list.Item(++i) + "', '" + _
list.Item(++i) + "', '" + _
list.Item(++i) + "', '" + _
list.Item(++i) + "', '" + _
list.Item(++i) + "', '" + _
list.Item(++i) + "', '" + _
list.Item(++i) + "', '" + _
list.Item(++i) + "', '" + _
list.Item(++i) + "', '" + _
list.Item(++i) + "', '" + _
list.Item(++i) + "', '" + _
list.Item(++i) + "', '" + _
list.Item(++i) + "', '" + _
list.Item(++i) + "', '" + _
list.Item(++i) + "')")
Next
++ i在参数中根本没有增加。
由于
答案 0 :(得分:0)
你需要使用循环变量(x)并以这种方式增加索引。
我在C#中这样做,但我相信你会明白的。
string sql = "INSERT INTO Contact VALUES ('";
for(int i = 1; i < list.Count ; i++)
{
sql += list.Item(i) + "', '";
}
sql = sql.Remove(sql.Length -1);
sql += ")";
Database.ExecuteCommand(sql);
答案 1 :(得分:0)
VB.Net没有增量运算符。
答案 2 :(得分:0)
添加此功能
Function GetIncrementValue(ByRef x as Integer) as Integer
x=x+1
Return x
End function
您的守则将......
Dim i As Integer = 0
For x As Integer = 1 To list.Count / 19
database.ExecuteCommand("INSERT INTO Contacts VALUES ('" + _
list.Item(i) + "', '" + _
list.Item(GetIncrementValue(i)) + "', '" + _
list.Item(GetIncrementValue(i)) + "', '" + _
list.Item(GetIncrementValue(i)) + "', '" + _
list.Item(GetIncrementValue(i)) + "', '" + _
list.Item(GetIncrementValue(i)) + "', '" + _
list.Item(GetIncrementValue(i)) + "', '" + _
list.Item(GetIncrementValue(i)) + "', '" + _
list.Item(GetIncrementValue(i)) + "', '" + _
list.Item(GetIncrementValue(i)) + "', '" + _
list.Item(GetIncrementValue(i)) + "', '" + _
list.Item(GetIncrementValue(i)) + "', '" + _
list.Item(GetIncrementValue(i)) + "', '" + _
list.Item(GetIncrementValue(i)) + "', '" + _
list.Item(GetIncrementValue(i)) + "', '" + _
list.Item(GetIncrementValue(i)) + "', '" + _
list.Item(GetIncrementValue(i)) + "', '" + _
list.Item(GetIncrementValue(i)) + "', '" + _
list.Item(GetIncrementValue(i)) + "')")
Next
享受....