Imports System.IO.File Imports System.IO Imports System.Data.SqlClient Imports System.Data.SqlTypes Imports System.ComponentModel Public Class Form1 #Region "Deklarationen" Dim ds As New DataSet() Dim ds2 As New DataSet #End Region Dim params As New Parameters Private Sub BeendenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BeendenToolStripMenuItem.Click Me.Close() End Sub #Region "Allgemeine Funktionalitäten" Private Function Insert_Journal(ByVal txt As String) If Me.Journal.Text <> "" Then Me.Journal.Text = Me.Journal.Text + vbCrLf If txt.IndexOf("Start") > -1 Then txt = txt & " : " & Now.ToString End If If txt.IndexOf("Ende") > -1 Then txt = txt & " : " & Now.ToString End If Me.Journal.Text = Me.Journal.Text + txt If txt.IndexOf("Ende") > -1 Then If txt.IndexOf("--->") < 0 Then Me.Journal.Text = Me.Journal.Text + vbCrLf Me.Journal.Text = Me.Journal.Text + "*******************" Me.Journal.Text = Me.Journal.Text + vbCrLf Me.Journal.Text = Me.Journal.Text + vbCrLf End If End If Windows.Forms.Application.DoEvents() End Function Private Function Printheader(ByVal Filenumber As Integer, ByVal Text As String) Dim s As String Dim l As Integer = 0 s = "/************************************************************************************/" l = Len(s) PrintLine(1, s) s = "/* Coldabgleich: " & Text While Len(s) < (l - 2) s = s & " " End While s = s & "*/" PrintLine(1, s) s = "/* " & Now.ToLongDateString & " / " & Now.ToLongTimeString While Len(s) < (l - 2) s = s & " " End While s = s & "*/" PrintLine(1, s) s = "/************************************************************************************/" PrintLine(1, s) End Function Private Function Printfooter(ByVal Filenumber As Integer) Dim s As String Dim l As String s = "/************************************************************************************/" l = Len(s) PrintLine(1, s) s = "/* End of File " While Len(s) < (l - 2) s = s & " " End While s = s & "*/" PrintLine(1, s) s = "/* " & Now.ToLongDateString While Len(s) < (l - 2) s = s & " " End While s = s & "*/" PrintLine(1, s) s = "/************************************************************************************/" PrintLine(1, s) End Function #End Region #Region "ZV-Belege" Private Sub ZVStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ZVStart.Click 'Vergleichstabellen generieren If Me.zvchk0.Checked = True Then Insert_Journal("Start Vergleichstabellen generieren") zv_gen_vergleichstabellen() Insert_Journal("Ende Vergleichstabellen generieren") End If 'Bereich ZV-Belege If Me.zvchk1.Checked = True Then Insert_Journal("Start fehlende Dokumente in EDOKA_ZV") ZV_Fehlende_Dokumente_In_EDOKA_ZV() If ds.Tables(0).Rows.Count > 0 Then Insert_Journal("---> Start Generierung Insert-Statements") ZV_Gen_Insert_Fehlende_Dokumente() Insert_Journal("---> Ende Generierung Insert-Statements") End If Insert_Journal("Ende Fehlende Dokumente in EDOKA_ZV") End If If Me.zvchk2.Checked = True Then Insert_Journal("Start Überzählige Dokumente in EDOKA_ZV") ZV_Ueberzaehlige_Dokumente_In_EDOKA_ZV() If ds.Tables(0).Rows.Count > 0 Then Insert_Journal("---> Start Generierung Delete-Statements") ZV_Gen_Del_Statements() Insert_Journal("---> Ende Generierung Delete-Statements") End If Insert_Journal("Ende überzählige Dokumente in EDOKA_ZV") End If If Me.zvchk3.Checked = True Then Insert_Journal("Start doppelte Dokumente in EDOKA_ZV") ZV_Doppelte_Dokumente_In_EDOKA_ZV() If ds.Tables(0).Rows.Count > 0 Then Insert_Journal("---> Start Generierung Delete-Statements") ZV_Doppelte_Gen_Del_Statements() Insert_Journal("---> Ende Generierung Delete-Statements") Insert_Journal("---> Start Generierung Insert-Statements") ZV_Doppelte_Gen_Ins_Statements() Insert_Journal("---> Ende Generierung Insert-Statements") End If Insert_Journal("Ende doppelte Dokumente in EDOKA_ZV") End If Me.Journal.SelectionStart = Me.Journal.Text.Length If Me.zvchk4.Checked = True Then Insert_Journal("Start Attribut-Abgleich") ZV_Attribut_Abgleich() If ds.Tables(0).Rows.Count > 0 Then Insert_Journal("---> Start Generierung Update-Statements") ZV_Gen_Attribut_Update() Insert_Journal("---> Ende Generierung Update-Statements") End If Insert_Journal("Ende Attributabgleich") End If If Me.zvchk5.Checked = True Then Insert_Journal("Start Nicht zugeordnete Dokumente") ZV_Nicht_Zugeordnete_Dokumente() Insert_Journal("Ende Nicht zugeordnete Dokumente") End If End Sub #Region "Vergleichstabellen generieren" Private Sub ZV_Gen_Vergleichstabellen() ds.Tables.Clear() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "zv_gen_compare_tables" sqlcmd.Parameters.Add("@von", SqlDbType.DateTime, 8) sqlcmd.Parameters.Add("@bis", SqlDbType.DateTime, 8) sqlcmd.Parameters(0).Value = Me.zvdatumab.Text + " 00:00:00" sqlcmd.Parameters(1).Value = Me.zvdatumbis.Text + " 00:00:00" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds, "Datatable1") Catch ex As Exception Insert_Journal("-> Fehler!!!" & ex.Message) Finally 'Insert_Journal("-> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count))) connection.Close() da.Dispose() sqlcmd.Dispose() End Try End Sub #End Region #Region "Fehlende ZV-Dokumente in EDOKA_ZV" Private Sub ZV_Fehlende_Dokumente_In_EDOKA_ZV() ds.Tables.Clear() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "ZV_Fehlende_Dokumente_EDOKA_ZV" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds, "Datatable1") Catch ex As Exception Insert_Journal("-> Fehler!!!" & ex.Message) Finally Insert_Journal("-> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count))) connection.Close() da.Dispose() sqlcmd.Dispose() End Try End Sub Private Sub ZV_Gen_Insert_Fehlende_Dokumente() Insert_Journal("-----> Start Insert-Statements generieren") ds.Tables.Clear() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "ZV_Script_Insert_Fehlende_Dokumente" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds, "Datatable1") Catch ex As Exception Insert_Journal("-----> Fehler!!!" & ex.Message) Finally Insert_Journal("-----> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count))) connection.Close() da.Dispose() sqlcmd.Dispose() End Try Insert_Journal("-----> Ende Insert-Statements generieren") Insert_Journal("-----> Start Scriptdatei erstellen") ZV_Script_Insert_Statements() Insert_Journal("-----> Ende Scriptdatei erstellen") End Sub Private Sub ZV_Script_Insert_Statements() Try Me.ToolProgress.Value = 0 Me.ToolProgress.Maximum = Me.ds.Tables(0).Rows.Count Dim filename As String = params.ScriptPath & "\1_" & Format(Now, "yyyymmss_hhmmss") & "_ZV_Ins_Fehlende_Dokumente.sql" FileOpen(1, filename, OpenMode.Output) Dim i As Integer = 0 Printheader(1, "Insert fehlende Dokumente in EDOKA_ZV") Dim s As String For i = 0 To ds.Tables(0).Rows.Count - 1 Me.ToolProgress.Value = Me.ToolProgress.Value + 1 Windows.Forms.Application.DoEvents() s = ds.Tables(0).Rows(i).Item(0) s = s.Replace("[tmp_zv]", "[zvbelege_import]") PrintLine(1, s) PrintLine(1, "Go") PrintLine(1, "") Next Printfooter(1) FileClose(1) Insert_Journal("---> Filename: " & filename) Insert_Journal("-----> " & ds.Tables(0).Rows.Count & " Insert-Statements generiert") Catch ex As Exception Insert_Journal("-----> Fehler!!!" & ex.Message) End Try End Sub #End Region #Region "Überzählige ZV-Dokumente in EDOKA_ZV" Private Sub ZV_Ueberzaehlige_Dokumente_In_EDOKA_ZV() ds.Tables.Clear() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "ZV_Ueberzaehlige_Dokumente_EDOKA_ZV" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds, "Datatable1") Catch ex As Exception Insert_Journal("-> Fehler!!!" & ex.Message) Finally Insert_Journal("-> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count))) connection.Close() da.Dispose() sqlcmd.Dispose() End Try End Sub Private Sub ZV_Gen_Del_Statements() Try Me.ToolProgress.Value = 0 Me.ToolProgress.Maximum = Me.ds.Tables(0).Rows.Count Dim filename As String = params.ScriptPath & "\2_" & Format(Now, "yyyymmss_hhmmss") & "_ZV_Del_Ueberzaehlige_Dokumente.sql" FileOpen(1, filename, OpenMode.Output) Dim i As Integer = 0 Printheader(1, "Delete überzählige Dokumente in EDOKA_ZV") Dim s As String For i = 0 To ds.Tables(0).Rows.Count - 1 Me.ToolProgress.Value = Me.ToolProgress.Value + 1 Windows.Forms.Application.DoEvents() s = "Delete form edoka_zv.dbo.zvbelege_data where nrdot00='" & ds.Tables(0).Rows(i).Item("nrdot00") & "' " s = s & " and nrauf00='" & Trim(ds.Tables(0).Rows(i).Item("nrauf00")) & "' " s = s & " and nrdoc00='" & Trim(ds.Tables(0).Rows(i).Item("nrdoc00")) & "'" PrintLine(1, s) PrintLine(1, "Go") PrintLine(1, "") Next Printfooter(1) FileClose(1) Insert_Journal("---> Filename: " & filename) Insert_Journal("---> " & ds.Tables(0).Rows.Count & " Delete-Statements generiert") Catch ex As Exception Insert_Journal("---> Fehler!!!" & ex.Message) End Try End Sub #End Region #Region "Doppelte ZV-Dokument" Private Sub ZV_Doppelte_Dokumente_In_EDOKA_ZV() ds.Tables.Clear() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "ZV_Doppelte_Dokumente_EDOKA_ZV" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.Parameters.Add("@fnkt", SqlDbType.Int, 4) sqlcmd.Parameters(0).Value = 1 sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds, "Datatable1") Catch ex As Exception Insert_Journal("-> Fehler!!!" & ex.Message) Finally Insert_Journal("-> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count))) connection.Close() da.Dispose() sqlcmd.Dispose() End Try End Sub Private Sub ZV_Doppelte_Gen_Del_Statements() Try Me.ToolProgress.Value = 0 Me.ToolProgress.Maximum = Me.ds.Tables(0).Rows.Count / 2 Dim filename As String = params.ScriptPath & "\3_" & Format(Now, "yyyymmss_hhmmss") & "_ZV_Del_Doppelte_Dokumente.sql" FileOpen(1, filename, OpenMode.Output) Dim i As Integer = 0 Printheader(1, "Delete Doppelte Dokumente in EDOKA_ZV") Dim s As String For i = 0 To ds.Tables(0).Rows.Count - 1 Step 2 Me.ToolProgress.Value = Me.ToolProgress.Value + 1 Windows.Forms.Application.DoEvents() s = "Delete form edoka_zv.dbo.zvbelege_data where nrdot00='" & ds.Tables(0).Rows(i).Item("nrdot00") & "' " s = s & " and nrauf00='" & Trim(ds.Tables(0).Rows(i).Item("nrauf00")) & "' " s = s & " and nrdoc00='" & Trim(ds.Tables(0).Rows(i).Item("nrdoc00")) & "'" PrintLine(1, s) PrintLine(1, "Go") PrintLine(1, "") Next Printfooter(1) FileClose(1) Insert_Journal("---> Filename: " & filename) Insert_Journal("---> " & ds.Tables(0).Rows.Count / 2 & " Delete-Statements generiert") Catch ex As Exception Insert_Journal("---> Fehler!!!" & ex.Message) End Try End Sub Private Sub ZV_Doppelte_Gen_Ins_Statements() ds.Tables.Clear() ZV_Doppelte_Get_Insert_Statements() Try Me.ToolProgress.Value = 0 Me.ToolProgress.Maximum = Me.ds.Tables(0).Rows.Count / 2 Dim filename As String = params.ScriptPath & "\4_" & Format(Now, "yyyymmss_hhmmss") & "_ZV_Ins_Einzelne_Dokumente.sql" FileOpen(1, filename, OpenMode.Output) Dim i As Integer = 0 Printheader(1, "Insert einzlne Dokumente (Dopplte entfernt) in EDOKA_ZV") Dim s As String For i = 0 To ds.Tables(0).Rows.Count - 1 Step 2 Me.ToolProgress.Value = Me.ToolProgress.Value + 1 Windows.Forms.Application.DoEvents() s = ds.Tables(0).Rows(i).Item(0) s = s.Replace("[tmp_zv_doppelte]", "[zvbelege_import]") PrintLine(1, s) PrintLine(1, "Go") PrintLine(1, "") Next Printfooter(1) FileClose(1) Insert_Journal("---> Filename: " & filename) Insert_Journal("-----> " & ds.Tables(0).Rows.Count / 2 & " Insert-Statements generiert") Catch ex As Exception Insert_Journal("-----> Fehler!!!" & ex.Message) End Try End Sub Private Sub ZV_Doppelte_Get_Insert_Statements() ds.Tables.Clear() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "ZV_Doppelte_Dokumente_EDOKA_ZV" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.Parameters.Add("@fnkt", SqlDbType.Int, 4) sqlcmd.Parameters(0).Value = 2 sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds, "Datatable1") Catch ex As Exception Insert_Journal("---> Fehler!!!" & ex.Message) Finally Insert_Journal("---> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count / 2))) connection.Close() da.Dispose() sqlcmd.Dispose() End Try End Sub #End Region #Region "Attributabgleich ZV" Private Sub ZV_Attribut_Abgleich() ds.Tables.Clear() ds2.Tables.Clear() ZV_Attribut_Abgleich_DoAbgleich() ZV_Attribut_Abgleich_Get_Table1() ZV_Attribut_Abgleich_Get_Table2() End Sub Private Sub ZV_Attribut_Abgleich_DoAbgleich() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "ZV_Attributvergleich" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.Parameters.Add("@fnkt", SqlDbType.Int) sqlcmd.Parameters(0).Value = 1 sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds, "Datatable1") 'Insert_Journal("-> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count))) Catch ex As Exception Insert_Journal("-> Fehler!!!" & ex.Message) Finally connection.Close() da.Dispose() sqlcmd.Dispose() End Try End Sub Private Sub ZV_Attribut_Abgleich_Get_Table1() ds.Tables.Clear() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "zv_Attributvergleich" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.Parameters.Add("@fnkt", SqlDbType.Int) sqlcmd.Parameters(0).Value = 2 sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds, "Datatable1") Insert_Journal("-> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count))) Catch ex As Exception Insert_Journal("-> Fehler!!!" & ex.Message) Finally connection.Close() da.Dispose() sqlcmd.Dispose() End Try End Sub Private Sub ZV_Attribut_Abgleich_Get_Table2() ds2.Tables.Clear() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "ZV_Attributvergleich" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.Parameters.Add("@fnkt", SqlDbType.Int) sqlcmd.Parameters(0).Value = 3 sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds2, "Datatable1") Insert_Journal("-> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count))) Catch ex As Exception Insert_Journal("-> Fehler!!!" & ex.Message) Finally connection.Close() da.Dispose() sqlcmd.Dispose() End Try End Sub Private Sub ZV_Gen_Attribut_Update() If ds.Tables(0).Rows.Count <> ds2.Tables(0).Rows.Count Then Insert_Journal("---> Fehler!!! Anzahl Datensätze Source/Dest nicht identisch)") Exit Sub End If Try Me.ToolProgress.Value = 0 Me.ToolProgress.Maximum = Me.ds.Tables(0).Rows.Count Dim filename As String = params.ScriptPath & "\5_" & Format(Now, "yyyymmss_hhmmss") & "_ZV_Attribut_Update.sql" FileOpen(1, filename, OpenMode.Output) Dim i As Integer = 0 Dim ii As Integer = 0 Printheader(1, "Update Attribute in EDOKA_HOST ") 'ds = Cold-Tabelle 'ds2 = EDOKA-Tabelle Dim dr1 As DataRow Dim dr2 As DataRow Dim s As String Dim cnt As Integer = 0 For i = 0 To ds.Tables(0).Rows.Count - 1 dr1 = ds.Tables(0).Rows(i) dr2 = ds2.Tables(0).Rows(i) If dr1.Item("nrdoc00") <> dr2.Item("nrdoc00") And dr1.Item("nrdot00") <> dr1.Item("nrdot00") And dr1.Item("nrauf00") <> dr2.Item("nrauf00") Then Insert_Journal("---> Fehler!!! Daten Source/Dest nicht synchron: " & dr1.Item("nrdot00") & "/" & dr1.Item("nrauf00") & "/" & dr1.Item("nrdoc00")) Exit Sub End If For ii = 1 To ds.Tables(0).Columns.Count - 1 If dr1.Item(ii) <> dr2.Item(ii) Then s = "Update edoka_zv.dbo.zvbelege_data set " & ds.Tables(0).Columns(ii).ColumnName & "='" & dr1.Item(ii) & "'" s = s & " where nrdot00='" & ds.Tables(0).Rows(i).Item("nrdot00") & "' " s = s & " and nrauf00='" & Trim(ds.Tables(0).Rows(i).Item("nrauf00")) & "' " s = s & " and nrdoc00='" & Trim(ds.Tables(0).Rows(i).Item("nrdoc00")) & "'" PrintLine(1, s) cnt = cnt + 1 End If Next Windows.Forms.Application.DoEvents() PrintLine(1, "Go") PrintLine(1, "") Next Insert_Journal("---> Anzahl Update-Statements generiert: " & Trim(Str(cnt))) Printfooter(1) FileClose(1) Insert_Journal("---> Filename: " & filename) Catch ex As Exception Insert_Journal("---> Fehler!!!" & ex.Message) End Try End Sub #End Region #Region "Nicht zugeordnete Dokumente" Private Sub ZV_Nicht_Zugeordnete_Dokumente() Insert_Journal("---> Start Prüfung nicht zugeordnete Partner_Inhaber") ZV_Nicht_Zugeordnete_Partner() If ds.Tables(0).Rows.Count > 0 Then Insert_Journal("---> Start Generierung Nicht zugeordnete Partner") ZV_Print_Nicht_Zugeordnete_Partner() Insert_Journal("---> Ende Generierung Nicht zugeordnete Partner") End If Insert_Journal("---> Ende Prüfung nicht zugeordnete Partner") End Sub Private Sub ZV_Nicht_Zugeordnete_Partner() ds.Tables.Clear() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand 'Dim res As IAsyncResult = sqlcmd.BeginExecuteReader(CommandBehavior.CloseConnection) sqlcmd.CommandText = "ZV_nicht_zugeordnete_dokumente" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.Parameters.Add("@fnkt", SqlDbType.Int) sqlcmd.Parameters(0).Value = 1 sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds, "Datatable1") Insert_Journal("---> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count))) Catch ex As Exception Insert_Journal("---> Fehler!!!" & ex.Message) Finally connection.Close() da.Dispose() sqlcmd.Dispose() End Try End Sub Private Sub ZV_Print_Nicht_Zugeordnete_Partner() Try Me.ToolProgress.Value = 0 Me.ToolProgress.Maximum = Me.ds.Tables(0).Rows.Count Dim filename As String = params.ScriptPath & "\6_" & Format(Now, "yyyymmss_hhmmss") & "_ZV_Nicht_zuget_Partner_Inhaber.sql" FileOpen(1, filename, OpenMode.Output) Dim i As Integer = 0 Dim s As String Printheader(1, "EDOKA_ZV nicht zugeordnete Partnernr (nrpar00) ") For i = 0 To ds.Tables(0).Rows.Count - 1 PrintLine(1, ds.Tables(0).Rows(i).Item("nrdot00") & ", " & ds.Tables(0).Rows(i).Item("nrauf00") & ", " & ds.Tables(0).Rows(i).Item("nrdoc00") & ", " & ds.Tables(0).Rows(i).Item("nrpar00")) Next Insert_Journal("---> Anzahl nicht zugeordnete Partner_Inhaber: " & Trim(ds.Tables(0).Rows.Count)) Printfooter(1) FileClose(1) Insert_Journal("---> Filename: " & filename) Catch ex As Exception Insert_Journal("---> Fehler!!!" & ex.Message) End Try End Sub #End Region #End Region Private Sub HOST_Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HOST_Start.Click Me.Journal.Text = "" If Me.hostchk0.Checked = True Then Insert_Journal("Start Vergleichstabellen generieren") host_Gen_Vergleichstabellen() Insert_Journal("Ende Vergleichstabellen generieren") End If If Me.hostchk1.Checked = True Then Insert_Journal("Start fehlende Dokumente in EDOKA_HOST") HOST_Fehlende_Dokumente_In_EDOKA_HOST() 'If ds.Tables(0).Rows.Count > 0 Then ' Insert_Journal("---> Start Generierung Insert-Statements") ' HOST_Gen_Insert_Fehlende_Dokumente() ' Insert_Journal("---> Ende Generierung Insert-Statements") 'End If Insert_Journal("Ende Fehlende Dokumente in EDOKA_HOST") End If Me.Journal.SelectionStart = Me.Journal.Text.Length If Me.hostchk2.Checked = True Then Insert_Journal("Start Überzählige Dokumente in EDOKA_HOST") HOST_Ueberzaehlige_Dokumente_In_EDOKA_HOST() 'If ds.Tables(0).Rows.Count > 0 Then ' Insert_Journal("---> Start Generierung Delete-Statements") ' HOST_Gen_Del_Statements() ' Insert_Journal("---> Ende Generierung Delete-Statements") 'End If Insert_Journal("Ende überzählige Dokumente in EDOKA_HOST") End If Me.Journal.SelectionStart = Me.Journal.Text.Length If Me.hostchk3.Checked = True Then Insert_Journal("Start doppelte Dokumente in EDOKA_HOST") HOST_Doppelte_Dokumente_In_EDOKA_HOST() 'If ds.Tables(0).Rows.Count > 0 Then ' Insert_Journal("---> Start Generierung Delete-Statements") ' HOST_Doppelte_Gen_Del_Statements() ' Insert_Journal("---> Ende Generierung Delete-Statements") ' Insert_Journal("---> Start Generierung Insert-Statements") ' HOST_Doppelte_Gen_Ins_Statements() ' Insert_Journal("---> Ende Generierung Insert-Statements") 'End If Insert_Journal("Ende doppelte Dokumente in EDOKA_HOST") End If Me.Journal.SelectionStart = Me.Journal.Text.Length If Me.hostchk4.Checked = True Then Insert_Journal("Start Attribut-Abgleich") HOST_Attribut_Abgleich() If ds.Tables(0).Rows.Count > 0 Then Insert_Journal("---> Start Generierung Update-Statements") HOST_Gen_Attribut_Update() Insert_Journal("---> Ende Generierung Update-Statements") End If Insert_Journal("Ende Attributabgleich") End If Me.Journal.SelectionStart = Me.Journal.Text.Length If Me.hostchk5.Checked = True Then Insert_Journal("Start Nicht zugeordnete Dokumente") HOST_Nicht_Zugeordnete_Dokumente() Insert_Journal("Ende Nicht zugeordnete Dokumente") End If End Sub #Region "Host-Dokumente" #Region "Host Vergleichstabellen generieren" Private Sub host_Gen_Vergleichstabellen() ds.Tables.Clear() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "host_gen_compare_tables" sqlcmd.Parameters.Add("@von", SqlDbType.VarChar, 8) sqlcmd.Parameters.Add("@bis", SqlDbType.VarChar, 8) Dim s As String = Me.hostdatumab.Text s = s.Substring(6, 4) + s.Substring(3, 2) + s.Substring(0, 2) sqlcmd.Parameters(0).Value = s s = Me.hostdatumbis.Text s = s.Substring(6, 4) + s.Substring(3, 2) + s.Substring(0, 2) sqlcmd.Parameters(1).Value = s sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds, "Datatable1") Catch ex As Exception Insert_Journal("-> Fehler!!!" & ex.Message) Finally 'Insert_Journal("-> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count))) connection.Close() da.Dispose() sqlcmd.Dispose() End Try End Sub #End Region #Region "Fehlende HOST-Dokumente in EDOKA_HOST" Private Sub HOST_Fehlende_Dokumente_In_EDOKA_HOST() ds.Tables.Clear() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "HOST_Fehlende_Dokumente_EDOKA_HOST" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds, "Datatable1") Catch ex As Exception Insert_Journal("-> Fehler!!!" & ex.Message) Finally Insert_Journal("-> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count))) connection.Close() da.Dispose() sqlcmd.Dispose() End Try End Sub Private Sub HOST_Gen_Insert_Fehlende_Dokumente() Insert_Journal("-----> Start Insert-Statements generieren") ds.Tables.Clear() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "HOST_Script_Insert_Fehlende_Dokumente" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds, "Datatable1") Catch ex As Exception Insert_Journal("-----> Fehler!!!" & ex.Message) Finally Insert_Journal("-----> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count))) connection.Close() da.Dispose() sqlcmd.Dispose() End Try Insert_Journal("-----> Ende Insert-Statements generieren") Insert_Journal("-----> Start Scriptdatei erstellen") Host_Script_Insert_Statements() Insert_Journal("-----> Ende Scriptdatei erstellen") End Sub Private Sub Host_Script_Insert_Statements() Try Me.ToolProgress.Value = 0 Me.ToolProgress.Maximum = Me.ds.Tables(0).Rows.Count Dim filename As String = params.ScriptPath & "\1_" & Format(Now, "yyyymmss_hhmmss") & "_HOST_Ins_Fehlende_Dokumente.sql" FileOpen(1, filename, OpenMode.Output) Dim i As Integer = 0 Printheader(1, "Insert fehlende Dokumente in EDOKA_HOST") Dim s As String For i = 0 To ds.Tables(0).Rows.Count - 1 Me.ToolProgress.Value = Me.ToolProgress.Value + 1 Windows.Forms.Application.DoEvents() s = ds.Tables(0).Rows(i).Item(0) s = s.Replace("[tmp_host]", "[host_dokument_import]") PrintLine(1, s) PrintLine(1, "Go") PrintLine(1, "") Next Printfooter(1) FileClose(1) Insert_Journal("---> Filename: " & filename) Insert_Journal("-----> " & ds.Tables(0).Rows.Count & " Insert-Statements generiert") Catch ex As Exception Insert_Journal("-----> Fehler!!!" & ex.Message) End Try End Sub #End Region #Region "Überzählige Host-Dokumente in EDOKA_HOST" Private Sub HOST_Ueberzaehlige_Dokumente_In_EDOKA_HOST() ds.Tables.Clear() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "HOST_Ueberzaehlige_Dokumente_EDOKA_HOST" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds, "Datatable1") Catch ex As Exception Insert_Journal("-> Fehler!!!" & ex.Message) Finally Insert_Journal("-> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count))) connection.Close() da.Dispose() sqlcmd.Dispose() End Try End Sub Private Sub HOST_Gen_Del_Statements() Try Me.ToolProgress.Value = 0 Me.ToolProgress.Maximum = Me.ds.Tables(0).Rows.Count Dim filename As String = params.ScriptPath & "\2_" & Format(Now, "yyyymmss_hhmmss") & "_HOST_Del_Ueberzaehlige_Dokumente.sql" FileOpen(1, filename, OpenMode.Output) Dim i As Integer = 0 Printheader(1, "Delete überzählige Dokumente in EDOKA_HOST") Dim s As String For i = 0 To ds.Tables(0).Rows.Count - 1 Me.ToolProgress.Value = Me.ToolProgress.Value + 1 Windows.Forms.Application.DoEvents() s = "Delete from edoka_host.dbo.host_dokument_data where dokumentid='" & ds.Tables(0).Rows(i).Item("Dokumentid") & "'" PrintLine(1, s) PrintLine(1, "Go") PrintLine(1, "") Next Printfooter(1) FileClose(1) Insert_Journal("---> Filename: " & filename) Insert_Journal("---> " & ds.Tables(0).Rows.Count & " Delete-Statements generiert") Catch ex As Exception Insert_Journal("---> Fehler!!!" & ex.Message) End Try End Sub #End Region #Region "Doppelte HOST-Dokument" Private Sub HOST_Doppelte_Dokumente_In_EDOKA_HOST() ds.Tables.Clear() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "HOST_Doppelte_Dokumente_EDOKA_HOST" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.Parameters.Add("@fnkt", SqlDbType.Int, 4) sqlcmd.Parameters(0).Value = 1 sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds, "Datatable1") Catch ex As Exception Insert_Journal("-> Fehler!!!" & ex.Message) Finally Insert_Journal("-> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count))) connection.Close() da.Dispose() sqlcmd.Dispose() End Try End Sub Private Sub HOST_Doppelte_Gen_Del_Statements() Try Me.ToolProgress.Value = 0 Me.ToolProgress.Maximum = Me.ds.Tables(0).Rows.Count Dim filename As String = params.ScriptPath & "\3_" & Format(Now, "yyyymmss_hhmmss") & "_HOST_Del_Doppelte_Dokumente.sql" FileOpen(1, filename, OpenMode.Output) Dim i As Integer = 0 Printheader(1, "Delete Doppelte Dokumente in EDOKA_HOST") Dim s As String For i = 0 To ds.Tables(0).Rows.Count - 1 Me.ToolProgress.Value = Me.ToolProgress.Value + 1 Windows.Forms.Application.DoEvents() s = "Delete from edoka_host.dbo.host_dokument_data where dokumentid='" & ds.Tables(0).Rows(i).Item("Dokumentid") & "'" PrintLine(1, s) PrintLine(1, "Go") PrintLine(1, "") Next Printfooter(1) FileClose(1) Insert_Journal("---> Filename: " & filename) Insert_Journal("---> " & ds.Tables(0).Rows.Count & " Delete-Statements generiert") Catch ex As Exception Insert_Journal("---> Fehler!!!" & ex.Message) End Try End Sub Private Sub HOST_Doppelte_Gen_Ins_Statements() ds.Tables.Clear() HOST_Doppelte_Get_Insert_Statements() Try Me.ToolProgress.Value = 0 Me.ToolProgress.Maximum = Me.ds.Tables(0).Rows.Count Dim filename As String = params.ScriptPath & "\4_" & Format(Now, "yyyymmss_hhmmss") & "_HOST_Ins_Einzelne_Dokumente.sql" FileOpen(1, filename, OpenMode.Output) Dim i As Integer = 0 Printheader(1, "Insert einzlne Dokumente (Dopplte entfernt) in EDOKA_HOST") Dim s As String For i = 0 To ds.Tables(0).Rows.Count - 1 Step 2 Me.ToolProgress.Value = Me.ToolProgress.Value + 1 Windows.Forms.Application.DoEvents() s = ds.Tables(0).Rows(i).Item(0) s = s.Replace("[tmp_host_doppelte]", "[host_dokument_import]") PrintLine(1, s) PrintLine(1, "Go") PrintLine(1, "") Next Printfooter(1) FileClose(1) Insert_Journal("---> Filename: " & filename) Insert_Journal("-----> " & ds.Tables(0).Rows.Count / 2 & " Insert-Statements generiert") Catch ex As Exception Insert_Journal("-----> Fehler!!!" & ex.Message) End Try End Sub Private Sub HOST_Doppelte_Get_Insert_Statements() ds.Tables.Clear() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "HOST_Doppelte_Dokumente_EDOKA_HOST" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.Parameters.Add("@fnkt", SqlDbType.Int, 4) sqlcmd.Parameters(0).Value = 2 sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds, "Datatable1") Catch ex As Exception Insert_Journal("---> Fehler!!!" & ex.Message) Finally Insert_Journal("---> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count / 2))) connection.Close() da.Dispose() sqlcmd.Dispose() End Try End Sub #End Region #Region "Attributabgleich" Private Sub HOST_Attribut_Abgleich() ds.Tables.Clear() ds2.Tables.Clear() HOST_Attribut_Abgleich_DoAbgleich() HOST_Attribut_Abgleich_Get_Table1() HOST_Attribut_Abgleich_Get_Table2() End Sub Private Sub HOST_Attribut_Abgleich_DoAbgleich() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "HOST_Attributvergleich" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.Parameters.Add("@fnkt", SqlDbType.Int) sqlcmd.Parameters(0).Value = 1 sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds, "Datatable1") 'Insert_Journal("-> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count))) Catch ex As Exception Insert_Journal("-> Fehler!!!" & ex.Message) Finally connection.Close() da.Dispose() sqlcmd.Dispose() End Try End Sub Private Sub HOST_Attribut_Abgleich_Get_Table1() ds.Tables.Clear() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "HOST_Attributvergleich" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.Parameters.Add("@fnkt", SqlDbType.Int) sqlcmd.Parameters(0).Value = 2 sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds, "Datatable1") Insert_Journal("-> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count))) Catch ex As Exception Insert_Journal("-> Fehler!!!" & ex.Message) Finally connection.Close() da.Dispose() sqlcmd.Dispose() End Try End Sub Private Sub HOST_Attribut_Abgleich_Get_Table2() ds2.Tables.Clear() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "HOST_Attributvergleich" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.Parameters.Add("@fnkt", SqlDbType.Int) sqlcmd.Parameters(0).Value = 3 sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds2, "Datatable1") Insert_Journal("-> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count))) Catch ex As Exception Insert_Journal("-> Fehler!!!" & ex.Message) Finally connection.Close() da.Dispose() sqlcmd.Dispose() End Try End Sub Private Sub HOST_Gen_Attribut_Update() If ds.Tables(0).Rows.Count <> ds2.Tables(0).Rows.Count Then Insert_Journal("---> Fehler!!! Anzahl Datensätze Source/Dest nicht identisch)") Exit Sub End If Try Me.ToolProgress.Value = 0 Me.ToolProgress.Maximum = Me.ds.Tables(0).Rows.Count Dim filename As String = params.ScriptPath & "\5_" & Format(Now, "yyyymmss_hhmmss") & "_HOST_Attribut_Update.sql" FileOpen(1, filename, OpenMode.Output) Dim i As Integer = 0 Dim ii As Integer = 0 Printheader(1, "Update Attribute in EDOKA_HOST ") 'ds = Cold-Tabelle 'ds2 = EDOKA-Tabelle Dim dr1 As DataRow Dim dr2 As DataRow Dim s As String Dim cnt As Integer = 0 For i = 0 To ds.Tables(0).Rows.Count - 1 dr1 = ds.Tables(0).Rows(i) dr2 = ds2.Tables(0).Rows(i) If dr1.Item("Dokumentid") <> dr2.Item("Dokumentid") Then Insert_Journal("---> Fehler!!! Daten Source/Dest nicht synchron: " & dr1.Item("dokumentid")) Exit Sub End If For ii = 1 To ds.Tables(0).Columns.Count - 1 If dr1.Item(ii) Is System.DBNull.Value Then dr1.Item(ii) = "" If dr2.Item(ii) Is System.DBNull.Value Then dr2.Item(ii) = "" If dr1.Item(ii) <> dr2.Item(ii) Then s = "Update edoka_host.dbo.host_dokument_data set " & ds.Tables(0).Columns(ii).ColumnName & "='" & dr1.Item(ii) & "'" s = s + " where dokumentid ='" & ds.Tables(0).Rows(i).Item("Dokumentid") & "'" PrintLine(1, s) cnt = cnt + 1 End If Next Windows.Forms.Application.DoEvents() PrintLine(1, "Go") PrintLine(1, "") Next Insert_Journal("---> Anzahl Update-Statements generiert: " & Trim(Str(cnt))) Printfooter(1) FileClose(1) Insert_Journal("---> Filename: " & filename) Catch ex As Exception Insert_Journal("---> Fehler!!!" & ex.Message) End Try End Sub #End Region #Region "Nicht zugeordnete Dokumente" Private Sub HOST_Nicht_Zugeordnete_Dokumente() Insert_Journal("---> Start Prüfung nicht zugeordnete Partner_Inhaber") HOST_Nicht_Zugeordnete_Partner_Inhaber() If ds.Tables(0).Rows.Count > 0 Then Insert_Journal("---> Start Generierung Nicht zugeordnete Partner_Inhaber") HOST_Print_Nicht_Zugeordnete_Partner_Inhaber() Insert_Journal("---> Ende Generierung Nicht zugeordnete Partner_Inhaber") End If Insert_Journal("---> Ende Prüfung nicht zugeordnete Partner_Inhaber") Insert_Journal("---> Start Prüfung nicht zugeordnete Partner_Zusteller") HOST_Nicht_Zugeordnete_Partner_Zusteller() If ds.Tables(0).Rows.Count > 0 Then Insert_Journal("---> Start Generierung Nicht zugeordnete Partner_Zusteller") HOST_Print_Nicht_Zugeordnete_Partner_Zusteller() Insert_Journal("---> Ende Generierung Nicht zugeordnete Partner_Zusteller") End If Insert_Journal("---> Ende Prüfung nicht zugeordnete Partner_Zusteller") End Sub Private Sub HOST_Nicht_Zugeordnete_Partner_Inhaber() ds.Tables.Clear() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "HOST_nicht_zugeordnete_dokumente" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.Parameters.Add("@fnkt", SqlDbType.Int) sqlcmd.Parameters(0).Value = 1 sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds, "Datatable1") Insert_Journal("---> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count))) Catch ex As Exception Insert_Journal("---> Fehler!!!" & ex.Message) Finally connection.Close() da.Dispose() sqlcmd.Dispose() End Try End Sub Private Sub HOST_Print_Nicht_Zugeordnete_Partner_Inhaber() Try Me.ToolProgress.Value = 0 Me.ToolProgress.Maximum = Me.ds.Tables(0).Rows.Count Dim filename As String = params.ScriptPath & "\6_" & Format(Now, "yyyymmss_hhmmss") & "_HOST_Nicht_zuget_Partner_Inhaber.sql" FileOpen(1, filename, OpenMode.Output) Dim i As Integer = 0 Dim s As String Printheader(1, "EDOKA_HOST nicht zugeordnete Partnernr_Inhaber (Inrpar00_Inhaber) ") For i = 0 To ds.Tables(0).Rows.Count - 1 PrintLine(1, ds.Tables(0).Rows(i).Item("dokumentid") & ", " & ds.Tables(0).Rows(i).Item("inrpar00_inhaber")) Next Insert_Journal("---> Anzahl nicht zugeordnete Partner_Inhaber: " & Trim(ds.Tables(0).Rows.Count)) Printfooter(1) FileClose(1) Insert_Journal("---> Filename: " & filename) Catch ex As Exception Insert_Journal("---> Fehler!!!" & ex.Message) End Try End Sub Private Sub HOST_Nicht_Zugeordnete_Partner_Zusteller() ds.Tables.Clear() Dim connection As New SqlConnection() Dim da As New SqlDataAdapter("", connection) Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "HOST_nicht_zugeordnete_dokumente" sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Connection = connection sqlcmd.Parameters.Add("@fnkt", SqlDbType.Int) sqlcmd.Parameters(0).Value = 2 sqlcmd.CommandTimeout = 500000 Try connection.ConnectionString = params.ConnectionStringColdabgleich connection.Open() da.SelectCommand = sqlcmd da.Fill(ds, "Datatable1") Insert_Journal("---> Total Datensätze: " & Trim(Str(ds.Tables(0).Rows.Count))) Catch ex As Exception Insert_Journal("---> Fehler!!!" & ex.Message) Finally connection.Close() da.Dispose() sqlcmd.Dispose() End Try End Sub Private Sub HOST_Print_Nicht_Zugeordnete_Partner_Zusteller() Try Me.ToolProgress.Value = 0 Me.ToolProgress.Maximum = Me.ds.Tables(0).Rows.Count Dim filename As String = params.ScriptPath & "\7_" & Format(Now, "yyyymmss_hhmmss") & "_HOST_Nicht_zuget_Partner_Zusteller.sql" FileOpen(1, filename, OpenMode.Output) Dim i As Integer = 0 Dim s As String Printheader(1, "EDOKA_HOST nicht zugeordnete Partnernr_Zusteller (Inrpar00_Zusteller) ") For i = 0 To ds.Tables(0).Rows.Count - 1 PrintLine(1, ds.Tables(0).Rows(i).Item("dokumentid") & ", " & ds.Tables(0).Rows(i).Item("inrpar00_zusteller")) Next Insert_Journal("---> Anzahl nicht zugeordnete Partner_Zusteller: " & Trim(ds.Tables(0).Rows.Count)) Printfooter(1) FileClose(1) Insert_Journal("---> Filename: " & filename) Catch ex As Exception Insert_Journal("---> Fehler!!!" & ex.Message) End Try End Sub #End Region #End Region End Class