Syntax Error adding extra field to INSERT Query with vb.net

0

Morning all. When an operator replaces a tool in a large production machine he goes to a PC and fills out information on a program I created. Well I want to put in a timestamp when they actually log the change vs when they say they changed the tool. The program has been in production for a few months so this is a new addition. I created a hidden textbox and when Submit is pressed, it generates a current timestamp and is supposed to go into the database with this Query:

text_timestamp.Clear()
text_timestamp.Text = DateTime.Now
str = "Insert Into Log
(machine_num,change_date,change_time,timestamp,clock_num,toolnum,tool_description,cycle_num,meet_expected,change_reason,comments,inspected_by) values 
(@d1,@d2,@d3,@d4,@d5,@d6,@d7,@d8,@d9,@d10,@d11,@d12)"
        Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
        cmd.Parameters.Add(New OleDbParameter("@d1", combo_machine.Text))
        cmd.Parameters.Add(New OleDbParameter("@d2", text_changedate.Value.ToShortDateString))
        cmd.Parameters.Add(New OleDbParameter("@d3", combo_changetime.Text))
        cmd.Parameters.Add(New OleDbParameter("@d4", text_timestamp.Text))
        cmd.Parameters.Add(New OleDbParameter("@d5", text_clocknum.Text))
        cmd.Parameters.Add(New OleDbParameter("@d6", combo_toolnum.Text))
        cmd.Parameters.Add(New OleDbParameter("@d7", text_description.Text))
        cmd.Parameters.Add(New OleDbParameter("@d8", text_cyclenum.Text))
        cmd.Parameters.Add(New OleDbParameter("@d9", Meet))
        cmd.Parameters.Add(New OleDbParameter("@d10", Reason))
        cmd.Parameters.Add(New OleDbParameter("@d11", text_comments.Text))
        cmd.Parameters.Add(New OleDbParameter("@d12", text_signedoffby.Text))
        cmd.ExecuteNonQuery()
        myConnection.Close()
        MsgBox("Submitted")

So I changed my data adapter and made sure all columns are showing up properly and it errors out at the last saying there is a syntax error in the INSERT INTO line. It seems to only be looking for 11 lines instead of 12 because if I remove a line, no matter which, it works and I see it in my access database. Anyone tell me what I could be doing wrong?

DataSet:

image

and the error in studio:

image

Exception Details:

System.Data.OleDb.OleDbException occurred
HResult=0x80040E14
Message=Syntax error in INSERT INTO statement.
Source=Microsoft Office Access Database Engine
StackTrace:
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at WindowsApp3.Form1.submit_button_click(Object sender, EventArgs e) in C:\Users\userme\Documents\Visual Studio 2017\Projects\WindowsApp3 - Copy\WindowsApp3\Form1.vb:line 134
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, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at WindowsApp3.My.MyApplication.Main(String[] Args) in :line 81
vb.net
visual-studio
asked on Stack Overflow Aug 24, 2017 by Individual101 • edited Aug 24, 2017 by Individual101

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0