TargetInvocationException in vb.net

tombo82

Mitglied
Hallo, ich will eine MySQL DB auslesen, und die Daten in eine Dbase-Tabelle schreiben:

Code:
Dim start As String = DateTime.Now
        If File.Exists(pfad & "\I001\ITDOWNL\copydat.dbf") = True Then
         ....
        Else
            copytemp.Reset()
            sendmysqlstatement("select * from copytemp where status='0'", db)
            If copytemp.Rows.Count = 0 Then
                MessageBox.Show("Keine Bestellungen gefunden")
            Else
                Dim anz As String = copytemp.Rows.Count.ToString
                File.Copy(Application.StartupPath & "\copydat.dbf", pfad & "\I001\ITDOWNL\copydat.dbf")
                For i As Integer = 0 To copytemp.Rows.Count - 1
                    BackgroundWorker1.ReportProgress(i + 1)
                    copydatdbf("insert into copydat (spnrv,genrv,datum,wmznr,alanz,anzahl,kuenrv,kdnrv,tournr,astnr,bontext,vgeb,subhoehe,schl,preis,bearb,bdatum,bzeit,mwsatz,essenpos,kdnr,neubest,viele,enr) values ('" & copytemp.Rows(i).Item(0) & "','" & copytemp.Rows(i).Item(1) & "','" & copytemp.Rows(i).Item(2) & "','" & copytemp.Rows(i).Item(3) & "','" & copytemp.Rows(i).Item(4) & "','" & copytemp.Rows(i).Item(5) & "','" & copytemp.Rows(i).Item(6) & "','" & copytemp.Rows(i).Item(7) & "','" & copytemp.Rows(i).Item(8) & "','" & copytemp.Rows(i).Item(9) & "','" & copytemp.Rows(i).Item(10) & "','" & copytemp.Rows(i).Item(11) & "','" & copytemp.Rows(i).Item(12) & "','" & copytemp.Rows(i).Item(13) & "','" & copytemp.Rows(i).Item(14) & "','" & copytemp.Rows(i).Item(15) & "','" & copytemp.Rows(i).Item(16) & "','" & copytemp.Rows(i).Item(17) & "','" & copytemp.Rows(i).Item(18) & "','" & copytemp.Rows(i).Item(19) & "','" & copytemp.Rows(i).Item(20) & "',0,0,'" & copytemp.Rows(i).Item(23) & "')", pfad & "\I001\ITDOWNL")
                    Dim datum As String = copytemp.Rows(i).Item(2).ToString.Substring(6, 4) & "-" & copytemp.Rows(i).Item(2).ToString.Substring(3, 2) & "-" & copytemp.Rows(i).Item(2).ToString.Substring(0, 2)
                    sendmysqlstatement("update copytemp set status='1' where kdnrv=" & copytemp.Rows(i).Item(7) & " and genrv='" & copytemp.Rows(i).Item(1) & "' and datum='" & datum & "'", db)
                Next
                Dim ende As String = DateTime.Now
                copytemp.Reset()
                MessageBox.Show("fertig, " & anz & " wurden geholt!" & Chr(13) & "Benötigte Zeit: " & start & Chr(13) & ende)
            End If
        End If

das klappt bis zum 100. von 294 Datensätzen,
dann bekomme ich nen Fehler: TargetInvocationException wurde nicht behandelt

er fliegt dann bei dat.fill(copydat) raus und wirft dann die Fehlermeldung unten

Code:
Private Sub copydatdbf(ByVal selectCommand As String, ByVal pfad As String)
        Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & pfad & "';Extended Properties=dBASE IV;User ID=;Password=;")
        Dim dat As New OleDbDataAdapter(selectCommand, con)
        If con.State = ConnectionState.Closed Then
            con.Open()
        End If
        dat.Fill(copydat)
        con.Close()
    End Sub



Hier die komplette Fehlermeldung:
System.Reflection.TargetInvocationException wurde nicht behandelt.
Message="Ein Aufrufziel hat einen Ausnahmefehler verursacht."
Source="mscorlib"
StackTrace:
bei System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
bei System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
bei System.Delegate.DynamicInvokeImpl(Object[] args)
bei System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
bei System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
bei System.Threading.ExecutionContext.runTryCode(Object userData)
bei System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
bei System.Windows.Forms.Control.InvokeMarshaledCallbacks()
bei System.Windows.Forms.Control.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(Int32 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 System.Windows.Forms.Application.Run(ApplicationContext context)
bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
bei copydat_krücke_13.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:Zeile 81.
bei System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
bei System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
bei System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
bei System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
bei System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart()


Was bedeutet der Fehler und wie komme ich an alle 294 Datensätze?

Danke schonma, Tommi
 
Code:
"   bei System.Windows.Forms.ProgressBar.set_Value(Int32 value)\r\n   bei copydat_krücke_13.Form1.BackgroundWorker2_ProgressChanged(Object sender, ProgressChangedEventArgs e) in C:\\Dokumente und Einstellungen\\eggert\\Eigene Dateien\\Visual Studio 2005\\Projects\\copydat krücke 13\\copydat krücke 13\\Form1.vb:Zeile 591.\r\n   bei System.ComponentModel.ProgressChangedEventHandler.Invoke(Object sender, ProgressChangedEventArgs e)\r\n   bei System.ComponentModel.BackgroundWorker.OnProgressChanged(ProgressChangedEventArgs e)\r\n   bei System.ComponentModel.BackgroundWorker.ProgressReporter(Object arg)"

PS: Fehler gefunde, lag an der Progessbar...
Warum auch immer..
 

Neue Beiträge

Zurück