Hallo zusammen!
Ich habe folgendes Problem:
Ich möchte ein Programm schreiben (VB) mit dem ich auf Datenbanken zugreifen kann. Das hab ich schon mal gemacht, und da hats prächtig funktioniert...
Bei diesem Programm entsteht an der folgenden Stelle im Code (markiert mit -->) den unten aufgeführten Fehler:
Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim anzahl As Integer
'Try
con.Open()
cmd.CommandText = "update saldo set Konto-Nr = '" & txtKontoNr.Text() & "', Klient = '" & txtKlient.Text() & _
"', Saldo = '" & txtSaldo.Text() & "' where ObjNr = " & pnummer(ListBox1.SelectedIndex)
--> MsgBox(cmd.CommandText)
anzahl = cmd.ExecuteNonQuery()
If anzahl > 0 Then
MsgBox("Eintrag erfolgreich geändert", MsgBoxStyle.Information, "Ändern erfolgreich")
End If
' Catch ex As Exception
' MsgBox(ex.Message, MsgBoxStyle.Critical, "Fehler beim Ändern")
' End Try
con.Close()
AlleSehen()
End Sub
Fehler:
System.Data.OleDb.OleDbException wurde nicht behandelt.
ErrorCode=-2147217900
Message=Syntaxfehler in UPDATE-Anweisung.
Source=Microsoft JET Database Engine
StackTrace:
bei System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
bei System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
bei System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
bei System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
bei System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
bei System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
bei BankManager.Saldo.Button2_Click(Object sender, EventArgs e) in C:\Users\Raphael\Documents\Visual Studio 2008\Projects\BankManager\BankManager\BankingManagementCompontents\Saldo\Saldo.vb:Zeile 79.
bei System.Windows.Forms.Control.OnClick(EventArgs e)
bei System.Windows.Forms.Button.OnClick(EventArgs e)
bei System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ButtonBase.WndProc(Message& m)
bei System.Windows.Forms.Button.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
bei BankManager.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:Zeile 81.
bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart()
InnerException:
Sollte jemand wissen, was ich falsch gemacht habe, oder wie ich das Problem beheben kann, soll er sich bitte umgehend bei mir melden!
P.S. Den Code aus dem alten Projekt kopieren geht nicht! Hab ich schon probiert!
Ich habe folgendes Problem:
Ich möchte ein Programm schreiben (VB) mit dem ich auf Datenbanken zugreifen kann. Das hab ich schon mal gemacht, und da hats prächtig funktioniert...
Bei diesem Programm entsteht an der folgenden Stelle im Code (markiert mit -->) den unten aufgeführten Fehler:
Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim anzahl As Integer
'Try
con.Open()
cmd.CommandText = "update saldo set Konto-Nr = '" & txtKontoNr.Text() & "', Klient = '" & txtKlient.Text() & _
"', Saldo = '" & txtSaldo.Text() & "' where ObjNr = " & pnummer(ListBox1.SelectedIndex)
--> MsgBox(cmd.CommandText)
anzahl = cmd.ExecuteNonQuery()
If anzahl > 0 Then
MsgBox("Eintrag erfolgreich geändert", MsgBoxStyle.Information, "Ändern erfolgreich")
End If
' Catch ex As Exception
' MsgBox(ex.Message, MsgBoxStyle.Critical, "Fehler beim Ändern")
' End Try
con.Close()
AlleSehen()
End Sub
Fehler:
System.Data.OleDb.OleDbException wurde nicht behandelt.
ErrorCode=-2147217900
Message=Syntaxfehler in UPDATE-Anweisung.
Source=Microsoft JET Database Engine
StackTrace:
bei System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
bei System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
bei System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
bei System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
bei System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
bei System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
bei BankManager.Saldo.Button2_Click(Object sender, EventArgs e) in C:\Users\Raphael\Documents\Visual Studio 2008\Projects\BankManager\BankManager\BankingManagementCompontents\Saldo\Saldo.vb:Zeile 79.
bei System.Windows.Forms.Control.OnClick(EventArgs e)
bei System.Windows.Forms.Button.OnClick(EventArgs e)
bei System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ButtonBase.WndProc(Message& m)
bei System.Windows.Forms.Button.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
bei BankManager.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:Zeile 81.
bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart()
InnerException:
Sollte jemand wissen, was ich falsch gemacht habe, oder wie ich das Problem beheben kann, soll er sich bitte umgehend bei mir melden!
P.S. Den Code aus dem alten Projekt kopieren geht nicht! Hab ich schon probiert!