SQLite 多参数插入注意事项 insert multiple parameters

SQLite 多参数插入注意事项 insert multiple parameters,第1张

概述1.) Do not reuse a parameter 2.)  VALUES(@str, @new) ParameterName="@str." ParameterName="@new." As the error indicates, you are using the parameters @str and @new and adding two different parameters.



1.) Do not reuse a parameter

2.) VALUES(@str,@new) Parametername="@str." Parametername="@new."
As the error indicates,you are using the parameters @str and @new and adding two different parameters. Read the error message,it is there for a reason and told you exactly what is wrong! 3.) Here is how I would write it (in this context). using (sqliteConnection cnn = new sqliteConnection("Data Source=C://EEk.db"))
using (sqliteCommand cmd = Database.CreateCommand())
{
cmd.CommandText = "INSERT INTO test (FIEld1,fname) VALUES(@str,@new)";
cmd.Parameters.AdDWithValue("@str",textBox1.Text);
cmd.Parameters.AdDWithValue("@new",textBox2.Text);

cnn.open();
cmd.ExecuteNonquery();
cnn.Close();
} While you can use DbConnection and DbCommand and make a factory pattern sort of implementation (which I doubt is going here...) I suggest you do not. Use the sqliteConnection,sqliteCommand,etc. The provIDer specific objects generally have features that make Coding easIEr. In this case,the AdDWithValue method. 总结

以上是内存溢出为你收集整理的SQLite 多参数插入注意事项 insert multiple parameters全部内容,希望文章能够帮你解决SQLite 多参数插入注意事项 insert multiple parameters所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1183391.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存