Imports System.Data
Imports System.Data.SqlClient

Public Class NWindLogik

    Public Function GetBestellIDs() As List(Of Integer)
        Dim lstBestellIDs As New List(Of Integer)
        Using conVerbindung As New SqlConnection(My.Settings.NWindConnectionString)
            Dim cmdBestellIDs As New SqlCommand
            With cmdBestellIDs
                .CommandText = "SELECT orderid FROM orders"
                .Connection = conVerbindung
            End With

            conVerbindung.Open()
            Dim rdBestellIDs As SqlDataReader = cmdBestellIDs.ExecuteReader
            While rdBestellIDs.Read()
                lstBestellIDs.Add(rdBestellIDs(0))
            End While
        End Using
        Return lstBestellIDs
    End Function

    Public Function GetBestellDetails(ByVal BestellID As Integer) As DataTable
        Dim dtBestellDetails As New DataTable
        Using conVerbindung As New SqlConnection(My.Settings.NWindConnectionString)
            Dim cmdBestellDetails As New SqlCommand
            With cmdBestellDetails
                .CommandText = "SELECT * FROM [order details] WHERE orderid = " & BestellID
                .Connection = conVerbindung
            End With

            Dim daBestellDetails As New SqlDataAdapter(cmdBestellDetails)
            daBestellDetails.Fill(dtBestellDetails)
        End Using

        Return dtBestellDetails
    End Function

End Class
