При вставке данных в другую таблицу (слова) одной и той же базы данных с использованием той же техники я могу успешно вставить данные без ошибок. Это заставляет меня поверить, что мое значение SQLiteConnection «cnn» не является проблемой. Я позаботился о том, чтобы имена свойств объекта и полей в таблице были одинаковыми. В этой конкретной таблице нет первичного ключа, но я не уверен, проблема это или нет.
Код, который не работает:
Код: Выделить всё
using (IDbConnection cnn = new SQLiteConnection(connection))
{
foreach (bridgeRecord br in bridgeWords)
{
try
{
cnn.Execute("insert into bridge (engWord, spaWord, frequency, wordClass) values (@engWord, @spaWord, @frequency, @wordClass)", br);
}
catch (SQLiteException ex)
{
Console.WriteLine(ex);
}
}
}
Код: Выделить всё
using (IDbConnection cnn = new SQLiteConnection(connection))
{
foreach (Word w in words)
{
try
{
cnn.Execute("insert into words (word, wordSimplified, confidence, difficulty, wordClass, wordCategory, dateTestedLast, popularity, language) " +
"values (@word, @wordSimplified, @confidence, @difficulty, @wordClass, @wordCategory, @dateTestedLast, @popularity, @language)", w);
}
catch (SQLiteException ex)
{
wordsBouncedBack.Add(w.word);
continue;
}
}
}
Код: Выделить всё
class bridgeRecord
{
public string engWord;
public string spaWord;
public int frequency;
public string wordClass;
}
Код: Выделить всё
code = Unknown (-1), message = System.Data.SQLite.SQLiteException (0x80004005): unknown error
Insufficient parameters supplied to the command
at System.Data.SQLite.SQLiteStatement.BindParameter(Int32 index, SQLiteParameter param)
Любая помощь будет очень признательна. Это мой первый вопрос о переполнении стека, поэтому извините, если ответ слишком очевиден
Подробнее здесь: https://stackoverflow.com/questions/539 ... -command-w
Мобильная версия