public override void Connect_To_Database(StorageConfig config) { myConfig = config as SQLiteConfig; if (myConfig == null) throw new Exception("Database Config is NULL"); if (!FileNameLockObjects.ContainsKey(myConfig.DatabaseFile)) FileNameLockObjects.Add(myConfig.DatabaseFile,new object()); try { myDBConn = new SQLiteConnection(ConnectionString); myDBConn.Open(); if (myDBConn.State != System.Data.ConnectionState.Open) throw new Exception("Unable to Open Database. Storage:" + config.Name); } catch (SQLiteException ex) { throw ex; } catch (Exception ex) { throw ex; } }
private void cmdAddSQLiteStorage_Click(object sender, RoutedEventArgs e) { string val = "Storage_" + (grdStorages.Items.Count + 1); if (DotNetSiemensPLCToolBoxLibrary.General.InputBox.Show("Storage-Name", "Name of the Storage", ref val) == DialogResult.OK) { foreach (var tmp in ProtokollerConfiguration.ActualConfigInstance.Storages) { if (tmp.Name.ToLower().Trim() == val.ToLower().Trim()) { MessageBox.Show("A Storage with this Name already Exists!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } } SQLiteConfig storage = new SQLiteConfig() {Name = val}; ProtokollerConfiguration.ActualConfigInstance.Storages.Add(storage); } }
public override void Connect_To_Database(StorageConfig config) { myConfig = config as SQLiteConfig; if (myConfig == null) throw new Exception("Database Config is NULL"); try { string connString = string.Format("Data Source={0};Pooling=true;FailIfMissing=false", myConfig.DatabaseFile); myDBConn = new FbConnection(connString); myDBConn.Open(); if (myDBConn.State != System.Data.ConnectionState.Open) throw new Exception(); } catch (FbException ex) { throw ex; } catch (Exception ex) { throw ex; } }