Oledbexception Syntax Error In Insert
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies
Oledbexception Was Unhandled C#
of this site About Us Learn more about Stack Overflow the company oledbexception was unhandled syntax error in insert into statement Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up .OleDbException Syntax error in INSERT INTO statement [closed] up vote -1 down vote favorite My software generates a query to be inserted into my Access database, but the query that comes from my code, generates a System.Data.OleDb.OleDbException, with an additional information: Syntax error in INSERT INTO statement. Debugging the code, the query generated works fine if I try to insert through Access software. I really don't know why I'm getting this exception, my query is good! Code: OleDbConnection commodityDB = null; try { commodityDB = new OleDbConnection(connector); Console.WriteLine("Microsoft DB Connected!"); } catch (Exception ex) { Console.WriteLine("Error: Failed to create a database connection. \n{0}", ex.Message); return; } OleDbCommand cmder = new OleDbCommand(insert_txt,commodityDB); string insert = string.Format("INSERT INTO Comm2 (Commodity_Name, Month_Code, Year_Com, ComCode, TradeDate,Open,High,Low,Close,Vol,OI) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')", comName, comMonth, comYear, parts[0], parts[2], parts[3], parts[4], parts[5], parts[6], parts[7], parts[8]); commodityDB.Open(); cmder.CommandText = insert; cmder.ExecuteNonQuery(); myAccessConn.Close(); An example of the query generated: INSERT INTO Comm2 (Commodity_Name, Month_Code, Year_Com, ComCode, TradeDate, Open, High, Low, Close, Vol, OI) VALUES ('Australian Dollar', 'Y', '0', 'A6', '04/28/2014', '92740', '93157', '92435', '92568', '0', '0') It works fine! Not on the software though. c# sql .net share|improve this question edited May 5 '14 at 4:37 asked May 5 '14 at 3:22 Frederico Novack Amaral Pereir 123112 closed as unclear what you're asking by lpapp, gnat, Shankar Damodaran, nvoigt, Raging Bull May 5 '14 at 6:18 Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow http://stackoverflow.com/questions/23464284/oledbexception-syntax-error-in-insert-into-statement Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up oledb exception syntax error in insert into statement (0x80040E14) in C# up vote 1 down vote favorite I'm having and exception in my insert into statement.But http://stackoverflow.com/questions/28911465/oledb-exception-syntax-error-in-insert-into-statement-0x80040e14-in-c-sharp the data is inserting to the table correctly. can someone please show me the error in this code. private void btnAddNewSale_Click(object sender, EventArgs e) { string StrQuery; connection.Open(); OleDbCommand command = new OleDbCommand(); command.Connection = connection; for (int i = 0; i < DataGridViewAddSale.Rows.Count; i++) { StrQuery = "insert into BillItem (billNumber,storeItemNumber,numberOfItems,priceForEach,totalValue) values (" + txtBillNo.Text + ", "+ DataGridViewAddSale.Rows[i].Cells["ColCordNo"].Value + ", "+ DataGridViewAddSale.Rows[i].Cells["ColQty"].Value + ", " + DataGridViewAddSale.Rows[i].Cells["ColUnitPrice"].Value + " ," + DataGridViewAddSale.Rows[i].Cells["ColTotalValue"].Value + ");"; command.CommandText = StrQuery; command.ExecuteNonQuery(); } } Below isthe exception System.Data.OleDb.OleDbException (Ox8004OE14): Syntax error in INSERT INTO statement. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OIeDbHResult br) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Oata.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OIeDb.OleDbCommand.ExecuteReaderlnternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQueryo at Bsystem_1 ._1 .Form2.btnAddNewSale_Click(Object sender, EventArgs e) in c:\Users\jagath\Documents\Visual Studio 2013\Projects\Bsystem 1.1\Bsystem 1.1\Form2.cs:line 166 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, 1nt32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Wi
Tips/Tricks Top Articles Beginner Articles Technical Blogs Posting/Update Guidelines Article Help Forum Article Competition Submit an article or tip Post your Blog http://www.codeproject.com/Questions/211929/Syntax-error-in-Insert-into-statement-at quick answersQ&A Ask a Question View Unanswered Questions View All Questions... Linux questions C# questions ASP.NET questions SQL questions fabric questions discussionsforums All Message Boards... Application Lifecycle> Running http://p2p.wrox.com/asp-net-1-0-1-1-basics/43408-need-help-insert-into-statement-syntax-error.html a Business Sales / Marketing Collaboration / Beta Testing Work Issues Design and Architecture ASP.NET JavaScript C / C++ / MFC> ATL / WTL / STL Managed C++/CLI syntax error C# Free Tools Objective-C and Swift Database Hardware & Devices> System Admin Hosting and Servers Java .NET Framework Android iOS Mobile SharePoint Silverlight / WPF Visual Basic Web Development Site Bugs / Suggestions Spam and Abuse Watch features Competitions News The Insider Newsletter The Daily Build Newsletter Newsletter archive Surveys Product Showcase Research Library CodeProject Stuff syntax error in communitylounge Who's Who Most Valuable Professionals The Lounge  The Insider News The Weird & The Wonderful The Soapbox Press Releases Non-English Language > General Indian Topics General Chinese Topics help What is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum Site Map Advertise with us About our Advertising Employment Opportunities About Us Ask a Question All Questions All Unanswered FAQ Syntax error in Insert into statement at..... Rate this: Please Sign up or sign in to vote. See more: VS2008 VB Windows Visual-Studio , + Hi, I am using Vb.net,Access2007 and Wind7. I am getting this type of error msg.. cmd.ExecuteNonQuery() Run-time exception thrown : System.Data.OleDb.OleDbException - Syntax error in INSERT INTO statement. Problem is that this query is not working in my vb.net code but it is working in msaccess "sqlview". Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strquery As String = "Insert Into Images (PatientID,Image,ImageNumber) VALUES ('patient0050','patient00501.JPG','1')" Dim con As New OleDbConnection(objclsvariable.
Unanswered Topics Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics NEED HELP INSERT INTO statement syntax error User Name Remember Me? Password Reminder Password Register Register | FAQ | Members List | Calendar | Today's Posts | Search ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0. Search Forums Show Threads Show Posts Advanced Search Find All Thanked Posts Go to Page... Welcome to the p2p.wrox.com Forums. You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free . Thread Tools Display Modes #1 (permalink) June 2nd, 2006, 01:13 PM koco Authorized User Join Date: Dec 2005 Location: , , Yugoslavia. Posts: 28 Thanks: 0 Thanked 0 Times in 0 Posts NEED HELP INSERT INTO statement syntax error Please I need help with this error. I dont know what to do SQL statement: string reg; reg = "INSERT INTO Customer(Name, Surname,User, Pass, Address1, Email1)"; reg += " VALUE('" +first.Text+ "','" +second.Text+ "','" +user.Text+ "','" +pass.Text+ "','" +address1.Text+ "','" +email.Text+ "');"; Exception Details: System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. Source Error: Line 35: Line 36: connection.Open(); Line 37: command.ExecuteNonQuery(); Line 38: Line 39: Response.Redirect("product.aspx"); Source File: c:\Application development website\links\register.aspx Line: 37 Stack Trace: [OleDbException (0x80040e