Search code examples
vb.netvisual-studiovb6smo

IsSysAdmin on vb.net?


I'm converting old VB6 application to Vb.net appl. And just wanted to know is there wasy to check isSysAdimin in vb.net?

**VB6 code:**

 Set oSQL = New SQLServer
            oSQL.LoginSecure = True
            oSQL.Connect "" & "xxxxxxx"
            If oSQL.Issysadmin Then DBA = True

**VB.Net code:**

        Dim srvConn As New ServerConnection()
                srvConn.ServerInstance = "" & "xxxxxxx"
                srvConn.LoginSecure = True
                Dim oSQL As New Server(srvConn)
                If oSQL.IsSysAdmin? Then DBA = True

Solution

  • According to technet.microsoft.com...

    *This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

    The Issysadmin property reports membership in the fixed server role sysadmin for the SQL Distributed Management Objects (SQL-DMO) connection.

    On another note, this has been answered using LINQ here...