的命令參數不足MonoDroid上的SQLite數據庫中的表有一個簡單的插入語句。SQLite錯誤提供給Mono.Data.Sqlite.SqliteStatement.BindParameter
當插入到數據庫中,它說在Mono.Data.Sqlite.SqliteStatement.BindParameter
提供至命令
SQLite的錯誤參數不足,我認爲有任何錯誤,或者該錯誤消息具有誤導性。因爲我只有5個參數,我提供了5個參數,所以我不明白這是正確的。
我的代碼如下,任何幫助將不勝感激。
try { using (var connection = new SqliteConnection(ConnectionString)) { connection.Open(); using (var command = connection.CreateCommand()) { command.CommandTimeout = 0; command.CommandText = "INSERT INTO [User] (UserPK ,Name ,Password ,Category ,ContactFK) VALUES (@UserPK , @Name , @Password , @Category , @ContactFK)"; command.Parameters.Add(new SqliteParameter("@Name", "Has")); command.Parameters.Add(new SqliteParameter("@Password", "Has")); command.Parameters.Add(new SqliteParameter("@Cateogry", "")); command.Parameters.Add(new SqliteParameter("@ContactFK", DBNull.Value)); command.Parameters.Add(new SqliteParameter("@UserPK", DbType.Guid) {Value = Guid.NewGuid()}); var result = command.ExecuteNonQuery(); return = result > 0 ; } } } catch (Exception exception) { LogError(exception); }
謝謝你,這是尷尬的:) – 2013-04-29 04:25:44
@哈斯泰爾,不客氣,發生這種情況,:) – Habib 2013-04-29 04:26:51