fred666
Goto Top

In VB.NET Combobox füllen

Ich verwende SQL 2005 und Visual Studios 2010

Hi,

ich habe ein WinForm mit einer Combobox und möchte mir in dieser Combobox alle Tabellen einer Datenbank einfügen.

Um die Tabellen zu selektieren verwende ich folgenden SQL-Code:
SELECT name FROM dbo.sysobjects WHERE Type ='U' AND name <> 'sysdiagrams' ORDER BY name  

Kann mir da jemand weiterhelfen?!

Grüße Fred

Content-Key: 170759

Url: https://administrator.de/contentid/170759

Printed on: April 19, 2024 at 20:04 o'clock

Member: Berrnd
Berrnd Aug 02, 2011 at 12:58:57 (UTC)
Goto Top
Hi,

Beispiel: ;)
Using conn As SqlConnection = New SqlConnection("Data Source=deinserver;Initial Catalog=master;Integrated Security=True")  
    conn.Open()
    Using selectCmd As SqlCommand = New SqlCommand() With {.CommandText = "SELECT name FROM dbo.sysobjects WHERE Type ='U' AND name <> 'sysdiagrams' ORDER BY name", .Connection = conn}  
        Using sdr As SqlDataReader = selectCmd.ExecuteReader()
            Do While sdr.Read()
                Me.ComboBox1.Items.Add(sdr.GetString(0))
            Loop
        End Using
    End Using
    conn.Close()
End Using
Gruß - Bernd