SQL语句出错,该如何解决
SQL语句出错for (i 0 i ListBox3-Items -Count i++){DataModule35-ADOQuery6-SQL-Add(insert
SQL语句出错
for (i = 0; i < ListBox3->Items ->Count; i++)
{
DataModule35->ADOQuery6->SQL->Add("insert into CardAuthor(CardNo,Author) values('" + Edit1->Text.Trim() + "','" + ListBox3->Items->Strings[ListBox3->Items[i]]+"')");
//DataModule35->ADOQuery6->SQL->Add(sql);
DataModule35->ADOQuery6->ExecSQL();
DataModule35->ADOQuery6->Close();
}
会在 DataModule35->ADOQuery6->SQL->Add("insert into CardAuthor(CardNo,Author) values('" + Edit1->Text.Trim() + "','" + ListBox3->Items->Strings[ListBox3->Items[i]]+"')");
这一次提示错误:[C++ Error] Unit3.cpp(699): E2034 Cannot convert 'TStrings' to 'int'
[C++ Error] Unit3.cpp(699): E2342 Type mismatch in parameter 'Index' (wanted 'int', got 'TStrings')
请问该怎么解决?
[解决办法]ListBox3->Items->Strings[ListBox3->Items[i]]
改成:
ListBox3->Items->Strings[i]
即可
[解决办法]int(ListBox3->Items->Strings[ListBox3->Items[i]]+");
[解决办法]你把DataModule35->ADOQuery6->SQL->Add("insert into CardAuthor(CardNo,Author) values('" + Edit1->Text.Trim() + "','" + ListBox3->Items->Strings[ListBox3->Items[i]]+"')");
换成:
DataModule35->ADOQuery6->SQL->Add(strTemp.sprintf("insert into CardAuthor(CardNo,Author) values('%s','%s')",Edit1->Text.Trim(),ListBox3->Items->Strings[i]]));
既简单,看的又明白
[解决办法]ListBox3->Items->Strings[i] 即可
[解决办法]ListBox3->Items[i]
下标怎么能放这个的。