Imports Oracle.DataAccess.Client
Imports System.Data.SqlClient
Public Class frmSQLTest
    Public vSQL As String
    Public vstartwert As String


    Public Sub New() 'ByVal selectcommand As String, ByVal startwert As String, ByVal vdatasource As String, ByVal vUserID As String, ByVal vPassword As String, ByVal vDB_Art As String, Optional ByVal vInitialCatalog As String = "")
        ' Dieser Aufruf ist für den Windows Form-Designer erforderlich.
        InitializeComponent()

        ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
        Try

            vSQL = frmBGExportProfileigenschaften.vSQL
            GetDataFromMSSQL()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Fehler bei Laden des Formulares:")
        End Try

    End Sub
    Public Sub Werte(ByVal selectcommand As String, ByVal startwert As String, ByVal vdatasource As String, ByVal vUserID As String, ByVal vPassword As String, ByVal vDB_Art As String, Optional ByVal vInitialCatalog As String = "")
        vdatasource = vdatasource
        vUserID = vUserID
        vPassword = vPassword
        vInitialCatalog = vInitialCatalog
        vSQL = selectcommand
        vDB_Art = vDB_Art
    End Sub
    Private Sub tsbaktualisieren_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbaktualisieren.Click
        GetDataFromMSSQL()
    End Sub

    Sub GetDataFromMSSQL()
        Me.Cursor = Cursors.WaitCursor
        Try
            Dim Connection As New SqlConnection
            Dim Command As SqlCommand = Nothing
            Dim DataAdapter As SqlDataAdapter = Nothing
            Dim DataSet As DataSet = Nothing


            ' ConnectionString aufbauen (aus Settings auslesen)
            ' Verbindung zur Datenbank aufbauen
            Try
                Connection.ConnectionString = My.Settings.ConfigConnectionString
                Connection.Open()
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.Critical, "GetDataFromMSSQL - Fehler bei Verbindung zur Datenbank aufbauen:")
                Exit Sub
            End Try
            Dim ds As New DataSet

            ' SQL-Abfrage definieren
            Dim da As New SqlDataAdapter(vSQL, Connection)
            da.Fill(ds)
            Connection.Close()
            Me.BindingSource1.DataSource = ds.Tables(0)
            Me.DataGridView1.DataSource = Me.BindingSource1
            Me.BindingSource1.ResetBindings(True)
            Me.DataGridView1.Refresh()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "GetDataFromMSSQL -  Folgender Fehler trat auf")
        End Try
        Me.Cursor = Cursors.Default
    End Sub
End Class