当前位置: 首页 > 编程语言 > C#

SQLite错误Mono.Data.Sqlite.SqliteStatement.BindParameter中提供给命令的参数不足分享

时间:2023-04-10 19:42:57 C#

C#学习教程:SQLiteErrorInsufficientparameterssuppliedtocommandinMono.Data.Sqlite.SqliteStatement.BindParameter在MonoDroid上。它说,SQLiteerrorMono.Data.Sqlite.SqliteStatement.BindParameterInsufficientparameterssuppliedtothecommandwheninsertingintothedatabase我认为有一个错误,或者错误消息具有误导性。我不知道这将如何工作,因为我只有5个参数并且我提供了5个参数。我的代码如下,任何帮助将不胜感激。尝试使用(varconnection=newSqliteConnection(ConnectionString)){connection.Open();使用(varcommand=connection.CreateCommand()){command.CommandTimeout=0;command.CommandText="INSERTINTO[User](UserPK,Name,Password,Cat??egory,ContactFK)VALUES(@UserPK,@Name,@Password,@Category,@ContactFK)";command.Parameters.Add(newSqliteParameter("@Name","Has"));command.Parameters.Add(newSqliteParameter("@Password","Has"));command.Parameters.Add(newSqliteParameter("@Cateogry",""));command.Parameters.Add(newSqliteParameter("@ContactFK",DBNull.Value));command.Parameters.Add(newSqliteParameter("@UserPK",DbType.Guid){Value=Guid.NewGuid()});varresult=command.ExecuteNonQuery();返回=结果>0;}}}catch(异常异常){LogError(异常);}INSERT语句中@Category拼写与添加的参数不相同。你有:command.Parameters.Add(newSqliteParameter("@Cateogry",""));^^^^^^^^^^^//@Category它应该在的位置:将您的声明修改为:command.Parameters.Add(newSqliteParameter("@Category",""));这已经得到正确回答,但我想添加这个以获取更多信息:如果在INSERT语句中使用任何@Parameters与AddWithValue或.Add(newSqliteParameter...statement)拼写不同,也可以生成此特定的SQLite错误字符串。以上就是C#学习教程:SQLite报错Mono.Data.Sqlite.SqliteStatement.BindParameterTheparametersprovidedtothecommandareinsufficienttosharedallcontent.如果对大家有用,需要进一步了解C#学习教程,希望大家多加关注——本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处: