borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2009 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Problem with code on CD-ROM drive.)Next Topic (Turn on Numlock Key) New Topic New Poll Post Reply
AndreaVB Forum : VB.Net : error - SavInto.ExecuteNonQuery()
Poster Message
alsh3lan
Level: Trainee

Registered: 03-03-2009
Posts: 1

icon error - SavInto.ExecuteNonQuery()

hi all i have this problem that i don't know how to fix
this is the code in vb.net 2008  :
--------------------------------------

Dim n As String = Label16.Text
            Dim SavInto As New OleDb.OleDbCommand
            Dim ConStr As String = _
                "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =" & _
                Application.StartupPath & "\data\MyData.Mdb;Jet OLEDB: Database Password=alsh1023;"
            Dim Conn As New OleDbConnection(ConStr)
            SavInto.Connection = Conn
            SavInto.CommandType = CommandType.Text
            'TextBox1.Text = MaskedTextBox1.Text

            SavInto.CommandText = "UPDATE login SET user = '" & Trim(TextBox12.Text) & "', pass = '" & Trim(TextBox11.Text) & "' WHERE user ='" & n & "'"
            Conn.Open()

            SavInto.ExecuteNonQuery()
            Conn.Close()
            MsgBox("DATA SUCCESSFULLY UPDATED IN THE DATABASE")
            '''''''''''''''''''''''''''''''''
            

        End If
--------------------------------------
** (user) is primer key in database **
-------------------------------------
error:

Syntax error in UPDATE statement.


System.Data.OleDb.OleDbException was unhandled
  ErrorCode=-2147217900
  Message="Syntax error in UPDATE statement."
  Source="Microsoft JET 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 CYTOGENETICS_UNIT.USERS.SAVER() in D:\KHALID-ANAYSIS\KHALID-ANALYSIS\KHALID-ANALYSIS\USERS.vb:line 227    at CYTOGENETICS_UNIT.USERS.Button7_Click(Object sender, EventArgs e) in D:\KHALID-ANAYSIS\KHALID-ANALYSIS\KHALID-ANALYSIS\USERS.vb:line 202    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(Int32 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 System.Windows.Forms.Application.Run(ApplicationContext context)    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)    at CYTOGENETICS_UNIT.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81    at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)    at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)    at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)    at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()    at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)    at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)    at System.Activator.CreateInstance(ActivationContext activationContext)    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)    at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

[Edited by alsh3lan on 03-03-2009 at 03:48 PM GMT]

____________________________
alsh3lan

03-03-2009 at 03:47 PM
View Profile Send Email to User Show All Posts | Quote Reply
Tom
Level: Protégé

Registered: 24-03-2009
Posts: 5
icon Re: error - SavInto.ExecuteNonQuery()

Its hard to say what the problem is without seeing the complete Update statement including the values that are being passed to it at the time of the error.

I wonder what value is being assigned in "n" in your where clause

24-03-2009 at 01:36 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB.Net : error - SavInto.ExecuteNonQuery()
Previous Topic (Problem with code on CD-ROM drive.)Next Topic (Turn on Numlock Key) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2009 Andrea Tincaniborder