/// ------------------------------------------------------------------------------------ /// <summary> /// Opens a connection to an FW SQL server database on the specified machine. /// </summary> /// ------------------------------------------------------------------------------------ internal static SqlConnection FwConnection(string dbName, string machineName) { try { if (!String.IsNullOrEmpty(machineName) && StartSQLServer(true)) { string server = FwDBAccessInfo.GetServer(machineName); string connectionStr = String.Format(FwDBAccessInfo.ConnectionString, new[] { server, dbName, "FWDeveloper", "careful" }); var connection = new SqlConnection(connectionStr); connection.Open(); return(connection); } } catch (Exception e) { if (!s_showErrorOnConnectionFailure) { ErrorReport.NotifyUserOfProblem(e, LocalizationManager.GetString( "Miscellaneous.Messages.DataSourceReading.ErrorEstablishingSQLServerConnectionMsg", "An error occurred when trying to establish a connection to the '{0}' " + "database on the machine '{1}'."), dbName, machineName); } } return(null); }
/// ------------------------------------------------------------------------------------ internal static void Load() { if (s_dbAccessInfo == null) { // Find the file that contains information about connecting to an FW database. s_accessInfoFile = FileLocationUtilities.GetFileDistributedWithApplication(App.ConfigFolderName, "FwDBAccessInfo.xml"); s_dbAccessInfo = XmlSerializationHelper.DeserializeFromFile <FwDBAccessInfo>(s_accessInfoFile); } if (s_dbAccessInfo == null && ShowMsgOnFileLoadFailure) { ErrorReport.NotifyUserOfProblem(LocalizationManager.GetString( "Miscellaneous.Messages.DataSourceReading.LoadingDBAccessInfoErorMsg", "The file that contains information to access FieldWork databases " + "older than version 7.x '{0}' is either missing or corrupt. Until " + "this problem is corrected, FieldWorks data sources cannot be " + "accessed or added as data sources."), s_accessInfoFile); } }