Private Sub Combo1_Click()
Dim tblname
Dim antal
' tabellens namn
tblname = Combo1.Text
antal = Text1.Text
If antal = 0 Then
antal = 10
Text1.Text = antal
End If
' hämtar en tabell
sql = "select top " & antal & " * from " & tblname
Set rst = con.Execute(sql)
' fyller listviewkontrollen
Populate_ListView ListView1, rst
End Sub
Private Sub CmdEnd_Click()
Set rst = Nothing
Set con = Nothing
Unload Me
End Sub
Private Sub Form_Load()
' visa formen
Me.Show
Me.Refresh
' ansluter till sql-servern
Set con = CreateObject("adodb.connection")
con.Open "dsn=pellesoft.nu", "sa", ""
' hämtar alla tabeller från sql-servern
sql = "select name from sysobjects where type = 'U' order by name"
Set rst = con.Execute(sql)
If Not (rst.EOF Or rst.BOF) Then
Do While Not rst.EOF
Combo1.AddItem rst(0)
rst.MoveNext
Loop
End If
rst.Close
Combo1.Text = Combo1.List(0)
End Sub
Private Sub Form_Resize()
ListView1.Width = Me.Width - 500
CmdEnd.Left = ListView1.Width - CmdEnd.Width
End Sub