Jump to content

Erro em sintaxe de Access SQL


Go to solution Solved by bioshock,

Recommended Posts

Posted

Boas pessoal... Bem eu tenho este código

Dim command As New OleDb.OleDbCommand("INSERT INTO [admin] (username, password) VALUES (@usr, @pw)", con)
		command.Parameters.AddWithValue("@usr", Trim(TextBox1.Text))
		command.Parameters.AddWithValue("@pw", pw)
		command.ExecuteNonQuery()
		con.Close()

Simples... e é tudo strings...

Mas dá-me este erro... Syntax error in INSERT INTO statement. Não precebo :X eu utilizo esta sintaxe para outra parte do programa e funciona 5*

Mais detalhado o erro

A first chance exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll
System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Exceção não processada</Description><AppDomain>BibliotecaEscolar-contagemdeentradas.vshost.exe</AppDomain><Exception><ExceptionType>System.Data.OleDb.OleDbException, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Syntax error in INSERT INTO statement.</Message><StackTrace> em System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
em System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object&amp; executeResult)
em System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&amp; executeResult)
em System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
em System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
em WindowsApplication1.viewdata.Button2_Click(Object sender, EventArgs e) em D:\BibliotecaEscolar-contagemdeentradas\BibliotecaEscolar-contagemdeentradas\viewdata.vb:line 188
em System.Windows.Forms.Button.onmouseup(MouseEventArgs mevent)
em System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks)
em System.Windows.Forms.Control.WndProc(Message&amp; m)
em System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)
em System.Windows.Forms.Button.WndProc(Message&amp; m)
em System.Windows.Forms.Nativewindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
em System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp; msg)
em System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
em System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
em System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
em Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
em Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
em Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
em WindowsApplication1.My.MyApplication.Main(String[] Args) em 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
em System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
em Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
em System.Threading.ThreadHelper.ThreadStart()</StackTrace><ExceptionString>System.Data.OleDb.OleDbException (0x80040E14): Syntax error in INSERT INTO statement.
em System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
em System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object&amp; executeResult)
em System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&amp; executeResult)
em System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
em System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
em WindowsApplication1.viewdata.Button2_Click(Object sender, EventArgs e) em D:\BibliotecaEscolar-contagemdeentradas\BibliotecaEscolar-contagemdeentradas\viewdata.vb:line 188
em System.Windows.Forms.Button.onmouseup(MouseEventArgs mevent)
em System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks)
em System.Windows.Forms.Control.WndProc(Message&amp; m)
em System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)
em System.Windows.Forms.Button.WndProc(Message&amp; m)
em System.Windows.Forms.Nativewindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
em System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp; msg)
em System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
em System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
em System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
em Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
em Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
em Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
em WindowsApplication1.My.MyApplication.Main(String[] Args) em 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
em System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
em Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
em System.Threading.ThreadHelper.ThreadStart()</ExceptionString></Exception></TraceRecord>

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.