MonoDroid の SQLite データベースのテーブルへの単純な挿入ステートメントがあります。
データベースに挿入するとき、それは言います
SQLite エラー Mono.Data.Sqlite.SqliteStatement.BindParameter でコマンドに指定されたパラメータが不十分です
バグがあるか、エラー メッセージが誤解を招く可能性があると思います。私は 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);
}