Hi all
I have some C# code which uses SMO but on my machine dt.Rows.Count is zero. Could somebody please test this out and see if it works for them (perhaps it is not working for me because I am connected via VPN?). Many thanks
Paul Newton
using System; using System.Data; using Microsoft.SqlServer.Management.Smo; namespace EnumAvailableSqlServers { class Program { static void Main(string[] args) { DataTable dt = SmoApplication.EnumAvailableSqlServers(true); Console.WriteLine(dt.Rows.Count); foreach (DataRow dr in dt.Rows) { Console.WriteLine(dr["Name"]); Console.WriteLine(" " + dr["Server"]); Console.WriteLine(" " + dr["Instance"]); Console.WriteLine(" " + dr["Version"]); Console.WriteLine(" " + dr["IsLocal"]); } Console.WriteLine("Finished ..."); Console.ReadKey(); } } }
-----Original Message----- From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of Alan Bourke Sent: 30 April 2020 08:57 To: profoxtech@leafe.com Subject: Re: SQL Server Shared Management Objects (SMO)
Sent by an external sender ------------------------------
Paul
There is no COM interface to SQL-SMO, so you would have to create a .NET assembly with a COM-callable wrapper exposing the functions you want I think. Or even just a .NET EXE which dumps any results to a text file that the vfp SIDE CAN READ.