troubleshooting Question

converted code from c# to Vb and getting error

Avatar of jtammyg
jtammyg asked on
Microsoft SQL Server.NET ProgrammingMicrosoft SQL Server 2005
6 Comments1 Solution253 ViewsLast Modified:
Hi!

I have the following code which intends to get me a listbox of all the databases in a specific sql server. But I am getting an error at the

dim list as list = new list(32)   <---- i have no idea what this does...this was converted online through a website.

The error I am getting is:

too few type arguments to 'system.collections.generic.list(of T)'


any help you can give me on this will be greatly appreciated.

thanks!

Regards,

Tammy
Public Shared Function FindDatabases(ByVal server As String) As String()
        Dim connectionString As String = (TrustedConnection(server, "master") + ";Connection Timeout=3")
        Dim connection As SqlConnection = Nothing
        Dim command As SqlCommand = Nothing
        Dim reader As SqlDataReader = Nothing
        Dim list As List = New List(32)
        Try
            connection = New SqlConnection(connectionString)
            command = New SqlCommand("DECLARE @t TABLE(db sysname NOT NULL PRIMARY KEY) INSERT @t(db) SELECT name FROM master.dbo.sysdataba" & _
                "ses WITH(NOLOCK) WHERE name NOT IN(N'SpecialData',N'master',N'tempdb',N'model',N'msdb') AND" & _
                " HAS_DBACCESS(name)=1 SELECT db FROM @t WHERE OBJECT_ID(N'[' + db + N'].dbo.table_version','R') I" & _
                "S NOT NULL ORDER BY db", connection)
            connection.Open()
            reader = command.ExecuteReader((CommandBehavior.CloseConnection Or CommandBehavior.SingleResult))
 
            While reader.Read
                list.Add(reader.GetString(0))
 
            End While
        Finally
            If ((Not (reader) Is Nothing) _
                        AndAlso Not reader.IsClosed) Then
                reader.Close()
            End If
            If ((Not (connection) Is Nothing) _
                        AndAlso (connection.State <> ConnectionState.Closed)) Then
                connection.Close()
            End If
        End Try
        Return list.ToArray
    End Function
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros