Update Access Database considerations

Source: Internet
Author: User

I made a small website and reported an error when updating the table. There was a syntax error near the update statement. After searching for the Internet for half a day, I asked other people to know where the error was,

Paste the code.

Stringbuilder strsqlinset = new stringbuilder (); // The using system. Text namespace is required.

Strsqlinset. append ("Update styleinfo set [style] =" + styleinfo. style + ", [styleid] =" + styleinfo. styleid + ", [title] =" + styleinfo. title + ", [content] =" + styleinfo. content + "where id =" + styleinfo. ID + "");

If this is the case, an error will be reported because single quotation marks must be added before the text fields in the Access Table and numeric fields are not required. Therefore, single quotation marks ('field name') must be placed after each set field '), in addition, to define the field name and access reserved words, or keywords, for the sake of insurance, use [] to enclose the field name, such as [ID].

The correct code is as follows:

Strsqlinset. append ("Update styleinfo set [style] = '" + styleinfo. style + "', [styleid] =" + styleinfo. styleid + ", [title] = '" + styleinfo. title + "', [content] ='" + styleinfo. content + "'where [ID] =" + styleinfo. ID + "");

I can't tell if this is the case if the technology is limited.

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.