For help! When you use an Access database to insert data, the insert into statement is always incorrect, but in the same statement format, the SQL Server 2000 database is used. No error is returned!

Source: Internet
Author: User

Conn = "provider = Microsoft. Jet. oledb.4.0; Data Source =" + server. mappath ("test. mdb ");
Strconn = new oledbconnection (conn );
Strconn. open ();
Strsql = "insert into content (content) vlaues ('" + txtcontent + "')";
Cmd = new oledbcommand (strsql, strconn );
Cmd. executenonquery ();
Cmd. Dispose ();
Strconn. Close ();

A server error occurs in the "/test" application.
--------------------------------------------------------------------------------

The syntax of the insert into statement is incorrect.
Note: An unhandled exception occurs during the execution of the current Web request. Check the stack trace information for details about the error and the source of the error in the code.

Exception details: system. Data. oledb. oledbexception: syntax error of the insert into statement.

Source error:

Row 65: strsql = "insert into content (content) vlaues ('" + txtcontent + "')";
Row 66: cmd = new oledbcommand (strsql, strconn );
Row 67: cmd. executenonquery ();
Row 68: cmd. Dispose ();
Row 69: strconn. Close ();
 

Source File: C:/inetpub/wwwroot/test/webform1.aspx. CS row: 67

Stack trace:

[Oledbexception (0x80040e14): the syntax of the insert into statement is incorrect.]
System. Data. oledb. oledbcommand. executecommandtexterrorhandling (int32 hr) + 41
System. Data. oledb. oledbcommand. executecommandtextforsingleresult (tagdbparams dbparams, object & executeresult) + 174
System. Data. oledb. oledbcommand. executecommandtext (Object & executeresult) + 92
System. Data. oledb. oledbcommand. executecommand (commandbehavior behavior, object & executeresult) + 65
System. Data. oledb. oledbcommand. executereaderinternal (commandbehavior behavior, string method) + 112
System. Data. oledb. oledbcommand. executenonquery ()
Test. webform1.button1 _ click (Object sender, eventargs E) in C:/inetpub/wwwroot/test/webform1.aspx. CS: 67
System. Web. UI. webcontrols. Button. onclick (eventargs E)
System. Web. UI. webcontrols. Button. system. Web. UI. ipostbackeventhandler. raisepostbackevent (string eventargument)
System. Web. UI. Page. raisepostbackevent (ipostbackeventhandler sourcecontrol, string eventargument)
System. Web. UI. Page. raisepostbackevent (namevaluecollection postdata)
System. Web. UI. Page. processrequestmain () + 1277

 

--------------------------------------------------------------------------------
Version: Microsoft. NET Framework Version: 1.1.4322.573; ASP. NET version: 1.1.4322.573

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.