Imports System.Data Imports System.Data.SqlTypes Imports System.Data.SqlClient Imports System.ComponentModel Imports System.Drawing Imports System.Drawing.Color Imports System.IO Imports System.Threading Imports System.Windows.Forms Public Class Form1 Private Sub BeendenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Me.Close() End Sub Private Function Generic_Select() As DataTable Dim scmCmdToExecute As SqlCommand = New SqlCommand() Dim dbconn As New SqlConnection(Globals.sConnectionString) scmCmdToExecute.Connection = dbconn scmCmdToExecute.CommandTimeout = 200 scmCmdToExecute.CommandText = "sp_check_mail_blversand" scmCmdToExecute.CommandType = CommandType.StoredProcedure Dim jvon As Integer Dim jbis As Integer scmCmdToExecute.CommandType = CommandType.StoredProcedure Dim dtToReturn As DataTable = New DataTable() Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute) Try sdaAdapter.Fill(dtToReturn) Return dtToReturn Catch ex As Exception MsgBox(ex.Message) Finally scmCmdToExecute.Dispose() sdaAdapter.Dispose() End Try End Function Dim th As Thread Private Sub Get_Data() Try Dim f As New frmFortschritt f.Show() f.Refresh() Dim dt As New DataTable dt = Generic_Select() Me.DokList.DataSource = Nothing Me.DokList.DataSource = dt Me.DokList.DataMember = dt.TableName f.Close() Catch ex As Exception MsgBox(ex.Message) Finally End Try End Sub Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click Me.Close() End Sub Private Sub TSBtnExcelExport_Click(sender As Object, e As EventArgs) Handles TSBtnExcelExport.Click Cursor = Cursors.WaitCursor Dim fn As String = System.IO.Path.GetRandomFileName fn = fn.Substring(0, Len(fn) - 4) fn = "h:\tssettings" + "\" + fn Dim xls As New XLSLib.clsXLSLib xls.Write_Excel(fn, Me.DokList.DataSource) Dim fnn As String = fn + ".xls" Rename(fn, fnn) Process.Start(fnn) Cursor = Cursors.Default Exit Sub End Sub Private Sub ToolStripButton2_Click(sender As Object, e As EventArgs) Handles ToolStripButton2.Click th = New Thread(AddressOf Get_Data) th.IsBackground = True th.Start() End Sub End Class