Microsoft.BizTalk.Databases.dll is an unsupported assembly in BizTalk Server framework. It provides functionality to query the servers (SQL Server, Windows, Clusters, etc) and its database – if is a SQL Server - over the network. To do it, this assembly exposes 5 classes: BizTalkDatabaseInfo, Database, DatabaseCollection, Server, y ServerCollection; and each class have its own properties and methods.
The use of these classes is very easy, in the following example I query the SQL Server that exists in my network using ServerCollection y Server.
foreach (string name in Microsoft.BizTalk.Databases.ServerCollection.GetSqlServerNames())
{
Microsoft.BizTalk.Databases.Server server = new Microsoft.BizTalk.Databases.Server(name);
System.Console.WriteLine("Server name: " + server.Name);
System.Console.WriteLine("Platform Identifier: " + server.PlatformIdentifier.ToString());
System.Console.WriteLine("Type: " + server.Type.ToString());
System.Console.WriteLine("Version: " + server.Version.ToString());
}
Or, to query the databases in each SQL Server you can use the code that I show below. In the example, I query each database in SQL Server and I ask if the database is a BizTalk Database:
Microsoft.BizTalk.Databases.Server server = new Microsoft.BizTalk.Databases.Server("server_name");
bool isBtsDb = true;
foreach (Microsoft.BizTalk.Databases.Database database in server.GetDatabaseCollection())
{
System.Console.WriteLine("Database: " + database.Name);
try
{
isBtsDb = database.IsBizTalkDatabase;
if ( isBtsDb )
System.Console.WriteLine("///// Begin - BizTalk Database ");
}
catch
{
isBtsDb = false;
}
System.Console.WriteLine("Is BizTalk database: " + isBtsDb.ToString());
if (isBtsDb)
{
System.Console.WriteLine("BizTalk Db name: " + database.BizTalkDatabaseInfo.Name);
System.Console.WriteLine("BizTalk Db version: " + database.BizTalkDatabaseInfo.Version.ToString());
System.Console.WriteLine("BizTalk Db description: " + database.BizTalkDatabaseInfo.Description);
System.Console.WriteLine("///// End - BizTalk Database ");
}
}
The last functionality doesn’t work in Database class because when I ask if a database is a BizTalk Database using IsBizTalkDatabase property, Database class only checks for BizTalk Management DB and ignore another database.
Unfortunately, by this reason, you cannot use this property… I hope that Microsoft people can resolve this “issue” in the next version; it’ll be a great help.