Considerations for SQLite multi-parameter insert multiple parameters

Source: Internet
Author: User
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 wocould write it (in this context ). using (sqliteconnection CNN = new sqliteconnection ("Data Source = C: // Eek. DB ")
using (sqlitecommand cmd = database. createcommand ()
{< br> 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 ();
}< span style = "font-size: medium; "> 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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.