How do I connect to a CMDB from an Automation script?
In a C# block of an Automation script, you can connect to the CMDB of the Inventory & Asset Management module.
Refer to the following namespaces:
Skyline.DataMiner.SLDatabaseSystem.Data
Refer to the following DLL files:
C:\Skyline DataMiner\Files\SLDatabase.dll C:\Skyline DataMiner\Files\System.Data.dll C:\Skyline DataMiner\Files\System.XML.dll
Copy the following snippet in the C# block and make sure the database name matches the name that is specified in DB.xml:
String dbName = "db-name"; //Name must be identical to name defined in db.xml SLSql localConnection = null; SLConnectionManager manager = new SLConnectionManager(); if(manager != null) { localConnection = manager.GetConnection(dbName); } if(localConnection == null) { engine.GenerateInformation("Database connection failed"); return; } DataSet result = localConnection.Query("SELECT * FROM table");