I'm using System.Data.SqlClient.SqlConnectionStringBuilder to pull apart a connection string we save when loading data. In theory (although not yet in practice), the user could load the OM from one database and save to another. As the connection string is saved into the model on loading, I can compare it on saving:
Dim currentDB As New System.Data.SqlClient.SqlConnectionStringBuilder(DbF.ConStr)
Dim fileDB As New System.Data.SqlClient.SqlConnectionStringBuilder(P.ConStr)
If currentDB.DataSource <> fileDB.DataSource
OrElse currentDB.InitialCatalog <> fileDB.InitialCatalog Then
My question: is it also possible to load the OM from an Excel file, in which case the "connection string" saved into the OM will be the path to the file?
Is there a way to test the string to see if it is a database connection string before trying to pass it into SqlConnectionStringBuilder? That method throws, and while I could use Try around it and solve the problem, I am wondering if there is a canonical method of testing "is this string a connection string"?