我正在尝试将一些数据输入到我访问过的数据库中,但仅限于某些行(由于您在代码中会看到的条件)但是它会抛出错误:'查询输入必须包含至少一个表或查询“。但我不确定我需要做些什么来解决这个问题。
我的代码是:
for (int i = 0; i < numberOfPlayers; i++)
{
OleDbConnection connection = new OleDbConnection(CONNECTION STRING HERE);
OleDbCommand command = new OleDbCommand();
connection.Open();
command.CommandText = "INSERT INTO TotalPlayerName ([Team], [Complete]) VALUES ('1', true) WHERE Team = '' AND Complete = false AND Rating = " + team1List[i];
command.CommandType = CommandType.Text;
command.Connection = connection;
command.ExecuteNonQuery();
connection.Close();
}
答案 0 :(得分:1)
我认为你想更新一些不插入的行,所以语句必须看起来像
command.CommandText = "update TotalPlayerName set Team = '1', Complete = true WHERE Team = '' AND Complete = false AND Rating = " + team1List[i]
编辑:更正了SQL语法问题