#pragma warning restore 649 public override void CreateDatabase(string constr) { var csb = new FbConnectionStringBuilder(constr) { Pooling = false }; FbConnection.CreateDatabase(csb.ConnectionString, 16384, false, true); using (var con = new FbConnection(csb.ConnectionString)) using (var cmd = con.CreateCommand()) { con.Open(); #region bug drug block //cmd.CommandText = @"CREATE TABLE crdb (tid INTEGER, name CHAR(120));"; //cmd.ExecuteScalar(); //cmd.CommandText = @"DROP TABLE crdb;"; //cmd.ExecuteScalar(); #endregion #region init actions: register udf functions cmd.CommandText = @" DECLARE EXTERNAL FUNCTION strlen CSTRING(32767) RETURNS INTEGER BY VALUE ENTRY_POINT 'IB_UDF_strlen' MODULE_NAME 'ib_udf';"; cmd.ExecuteScalar(); #endregion } }
public override void ChangeDatabase(string db) { lock (this) { CheckClosed(); if (string.IsNullOrEmpty(db)) { throw new InvalidOperationException("Database name is not valid."); } string cs = _connectionString; try { FbConnectionStringBuilder csb = new FbConnectionStringBuilder(_connectionString); /* Close current connection */ Close(); /* Set up the new Database */ csb.Database = db; ConnectionString = csb.ToString(); /* Open new connection */ Open(); } catch (IscException ex) { ConnectionString = cs; throw new FbException(ex.Message, ex); } } }
public bool check_sysdba(string pass_) { bool yes_ = true; //проверим - установлен ли сервер FB string dir_ = get_install("Firebird 2.5"); if (dir_ != "") { FbConnectionStringBuilder fc_ch = new FbConnectionStringBuilder(); fc_ch.Database = temp_folder + @"\det.fdb";//база, которую нужно конвертировать fc_ch.Pooling = false; //пул соединения - отсутствует - для более быстрого освобождения базы //fc_old.Charset = "win1251"; //кодировка для FB 1/5 не указывается - здесь нужно было переводить в форматы UTF fc_ch.UserID = "sysdba";//пользователь по умолчанию fc_ch.Password = pass_; //Пароль можно не указывать try { if (!Directory.Exists(temp_folder)) { Directory.CreateDirectory(temp_folder); } FbConnection.CreateDatabase(fc_ch.ConnectionString, true); } catch (FbException ex) { MessageBox.Show(ex.Message, "Неверный пароль SYSDBA", MessageBoxButtons.OK, MessageBoxIcon.Error); yes_ = false; } } return yes_; }
private void btnCheck_Click(object sender, EventArgs e) { try { if (txtPath.Text.Split('@').Length == 2) { FbConnectionStringBuilder cnString = new FbConnectionStringBuilder(); cnString.DataSource = txtPath.Text.Split('@')[0]; cnString.Database = txtPath.Text.Split('@')[1]; cnString.UserID = "SYSDBA"; cnString.Password = "******"; cnString.Charset = "win1251"; cnString.Dialect = 3; using (FbConnection cn = new FbConnection(cnString.ToString())) { cn.Open(); FbCommand cmd = new FbCommand("SELECT PRICE.* FROM PRICE", cn); cmd.ExecuteNonQuery(); } MessageBox.Show("ok"); } else { MessageBox.Show("Не верный формат строки!"); } } catch(Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.Source); } }
static void Main(string[] args) { var builder = new FbConnectionStringBuilder(); builder.DataSource = "localhost"; builder.Database = @"D:\DB\FB3_EXTERNAL_TEST.FDB"; builder.Charset = FbCharset.Utf8.ToString(); builder.UserID = "SYSDBA"; builder.ServerType = FbServerType.Embedded; builder.ClientLibrary = @"fb\fbclient.dll"; //DB作成 if (!File.Exists(builder.Database)) { FbConnection.CreateDatabase(builder.ConnectionString); } //create procesure var dllPath = new Uri(new Uri(Assembly.GetEntryAssembly().Location), @"../../Fb/plugins/FbExternalSample.dll").LocalPath; var createSqls = new FbHelper().GetCreateStatements(dllPath); using (var con = new FbConnection(builder.ConnectionString)) using (var command = con.CreateCommand()) { con.Open(); foreach (var sql in createSqls) { command.CommandText = sql; command.ExecuteNonQuery(); } } //実行 var sqls = new[] { "SELECT * FROM HellowWorld('Taro')", "SELECT * FROM GetNumbers(5)", "SELECT * FROM GetDemo('やったぜ!')" }; using (var con = new FbConnection(builder.ConnectionString)) using (var command = con.CreateCommand()) { con.Open(); foreach (var sql in sqls) { Console.WriteLine("- SQL -"); Console.WriteLine(sql); Console.WriteLine("- 実行結果 -"); command.CommandText = sql; var reader = command.ExecuteReader(); while (reader.Read()) { var result = ""; for (var i = 0; i < reader.FieldCount; i++) { result += $" {reader[i]}"; } Console.WriteLine(result); } Console.WriteLine("------------------------------------"); } } Console.Read(); }
private bool DataBaseOpenConnection() { var fb_con = new FbConnectionStringBuilder { Charset = charset, UserID = userID, Password = password, Database = database, ServerType = 0 }; fb = new FbConnection(fb_con.ToString()); try { if (fb.State != ConnectionState.Open) { fb.Open(); } } catch (Exception ex) { Log.Add(ex.Message + "\r\n" + ex.Source + "\r\n" + ex.TargetSite); return false; } return true; }
public override async Task ChangeDatabaseAsync(string db, CancellationToken cancellationToken = default) #endif { CheckClosed(); if (string.IsNullOrEmpty(db)) { throw new InvalidOperationException("Database name is not valid."); } var oldConnectionString = _connectionString; try { var csb = new FbConnectionStringBuilder(_connectionString); /* Close current connection */ await CloseAsync().ConfigureAwait(false); /* Set up the new Database */ csb.Database = db; ConnectionString = csb.ToString(); /* Open new connection */ await OpenAsync(cancellationToken).ConfigureAwait(false); } catch (IscException ex) { ConnectionString = oldConnectionString; throw FbException.Create(ex); } }
public void InitDB() { bool newdb = false; Logger.Debug("Starting FbConnection"); Status = "Connecting"; FbConnectionStringBuilder builder = new FbConnectionStringBuilder(); builder.UserID = "SYSDBA"; builder.Database = Environment.GetFolderPath(Environment.SpecialFolder.Personal)+@"\RatTracker\EDDB.FDB"; builder.ServerType = FbServerType.Embedded; if (Thread.CurrentThread.Name == null) { Thread.CurrentThread.Name = "FireBirdWorker"; } if (File.Exists(_rtPath + @"\RatTracker\EDDB.FDB")) { Logger.Info("FBworker: EDDB database file found."); _dbReady = true; } else { Logger.Debug("Creating Database!"); Status = "Creating Database"; try { if (Directory.Exists(_rtPath + @"\RatTracker")) { Logger.Info("Creating database "+builder.ConnectionString+"."); FbConnection.CreateDatabase(builder.ConnectionString); _dbReady = true; } else { Directory.CreateDirectory(_rtPath+@"\RatTracker"); Logger.Info("Creating directory and database " + builder.ConnectionString); FbConnection.CreateDatabase(builder.ConnectionString); _dbReady = true; } newdb = true; } catch (Exception ex) { Logger.Debug("Oops. Couldn't create database, probably because I got launched for Oauth. Doing nothing. "+ex.Message); return; } } con = new FbConnection( _fbConStr); try { con.Open(); Logger.Info("FBWorker has connected to the database."); Status = "Connected"; if (newdb) CreateTables(); } catch (Exception ex) { Show(ex.ToString()); } }
public static DBSchema LoadSchema(string constr) { var csb = new FbConnectionStringBuilder(constr); //csb.Pooling = false; using (var con = new FbConnection(csb.ConnectionString)) { con.Open(); var dbsc = new DBSchema { Name = csb.Database, Tables = GetTables(con) }; foreach (var table in dbsc.Tables) { table.Keys = GetKeys(con, table).ToArray(); table.Indexes = GetIndexes(con, table).ToArray(); } dbsc.Generators = GetGenerators(con); return dbsc; } }
/// <summary> /// /// </summary> /// <param name="pathScript"></param> private void CreateEmbeddedDb(string pathScript) { FbConnectionStringBuilder csb = new FbConnectionStringBuilder(); csb.Charset = "UTF8"; csb.ServerType = FbServerType.Embedded; csb.Database = databaseName; csb.UserID = "SYSDBA"; csb.Password = "******"; try { if (!File.Exists(databaseName)) { OpenFileDialog filedialog = new OpenFileDialog(); DialogResult res = filedialog.ShowDialog(); filedialog.Title = "Wybierz skrypt sql do utworzenia bazy"; FbConnection.CreateDatabase(csb.ToString()); // parse the SQL script FbScript script = new FbScript(filedialog.FileName); script.Parse(); // execute the SQL script using (FbConnection c = new FbConnection(csb.ToString())) { FbBatchExecution fbe = new FbBatchExecution(c); foreach (string cmd in script.Results) { fbe.SqlStatements.Add(cmd); } fbe.Execute(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static bool check_func(FbConnectionStringBuilder fc) { bool res_ = false; using (FbConnection fb = new FbConnection(fc.ConnectionString)) { try { fb.Open(); using (FbTransaction ft = fb.BeginTransaction()) { using (FbCommand fcon = new FbCommand(sql_func,fb,ft)) { using (FbDataReader fr = fcon.ExecuteReader()) { while (fr.Read()) { res_ = true; } fr.Dispose(); } fcon.Dispose(); } ft.Commit(); ft.Dispose(); } } catch { } finally { fb.Close(); } fb.Dispose(); } return res_; }
static int Main(string[] args) { int i = 0; int max = args.Length < 1 ? 1 : int.Parse(args[0]); while (i < max) { var connectionBuilder = new FbConnectionStringBuilder(); connectionBuilder.DataSource = "localhost"; connectionBuilder.Database = @"D:\db\Hoge2.FDB"; connectionBuilder.Charset = FbCharset.Utf8.ToString(); connectionBuilder.UserID = "SYSDBA"; connectionBuilder.Password = "******"; connectionBuilder.ServerType = FbServerType.Embedded; connectionBuilder.Pooling = false; using (var connection = new FbConnection(connectionBuilder.ConnectionString)) { connection.Open(); connection.Close(); } i++; } UnloadDll(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), @"fbembed.dll")); return DateTime.Now.ToIntTime(); }
private async Task ChangeDatabaseImpl(string db, AsyncWrappingCommonArgs async) { CheckClosed(); if (string.IsNullOrEmpty(db)) { throw new InvalidOperationException("Database name is not valid."); } var oldConnectionString = _connectionString; try { var csb = new FbConnectionStringBuilder(_connectionString); /* Close current connection */ await CloseImpl(async).ConfigureAwait(false); /* Set up the new Database */ csb.Database = db; ConnectionString = csb.ToString(); /* Open new connection */ await OpenImpl(async).ConfigureAwait(false); } catch (IscException ex) { ConnectionString = oldConnectionString; throw FbException.Create(ex); } }
public FirebirdSQLDatabase() { string dllDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); // Register DLL and resource file directories - necessary for the driver, else it would try to // load resources from the application's directory Environment.SetEnvironmentVariable("FIREBIRD", dllDirectory); Environment.SetEnvironmentVariable("FIREBIRD_MSG", dllDirectory); FirebirdSettings settings = ServiceRegistration.Get<ISettingsManager>().Load<FirebirdSettings>(); FbConnectionStringBuilder sb = new FbConnectionStringBuilder { ServerType = settings.ServerType, UserID = settings.UserID, Password = settings.Password, Database = settings.DatabaseFile, Dialect = 3, Charset = "UTF8", Pooling = false, // We use our own pooling mechanism ReturnRecordsAffected = true }; _connectionString = sb.ConnectionString; try { string dir = Path.GetDirectoryName(settings.DatabaseFile); if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); if (!File.Exists(settings.DatabaseFile)) CreateDatabase(_connectionString); } catch (Exception e) { ServiceRegistration.Get<ILogger>().Critical("Error establishing database connection", e); throw; } }
public override void execute(Options options, INIManager iniManager) { string AppKey = iniManager.IniReadValue("APP", "AppKey"); string AppSecret = iniManager.IniReadValue("APP", "AppSecret"); string TaobaoAsistantPath = iniManager.IniReadValue("淘宝助理", "安装目录"); string nick = options.Nick; string SessionKey = iniManager.IniReadValue(nick, "SessionKey"); string userId = iniManager.IniReadValue(nick, "UserId"); if (userId == null || userId.Trim().Equals("")) { userId = "1696293148"; } StreamWriter MovePicLogWriter; FileStream MovePicLog = new FileStream(Environment.CurrentDirectory + "\\" + "MovePic.log", FileMode.Append); MovePicLogWriter = new StreamWriter(MovePicLog, Encoding.Default); FbConnectionStringBuilder cs = new FbConnectionStringBuilder(); cs.Database = Path.Combine(TaobaoAsistantPath, "users\\" + nick + "\\APPITEM.DAT"); cs.Charset = "UTF8"; cs.UserID = "SYSDBA"; cs.Password = "******"; cs.ServerType = FbServerType.Embedded; FbConnection fbCon = new FbConnection(cs.ToString()); fbCon.Open(); FbCommand ItemsCommand = null; ItemsCommand = new FbCommand("SELECT * FROM ITEM WHERE OUTER_ID = @SearchString OR TITLE = @SearchString", fbCon); FbParameter SearchString = new FbParameter("@SearchString", FbDbType.VarChar); SearchString.Value = options.Item; ItemsCommand.Parameters.Add(SearchString); FbDataReader ItemsReader = ItemsCommand.ExecuteReader(); while (ItemsReader.Read()) { MovePicLogWriter.WriteLine("--------------------------------------------------------------------------------"); Console.WriteLine("--------------------------------------------------------------------------------"); string ClientID = ItemsReader["CLIENT_ID"].ToString(); string Title = ItemsReader["TITLE"].ToString(); Console.WriteLine("ClientID=" + ClientID); MovePicLogWriter.WriteLine("ClientID=" + ClientID); Console.WriteLine("TITLE=" + Title); MovePicLogWriter.WriteLine("TITLE=" + Title); FbTransaction myTransaction = fbCon.BeginTransaction(); FbCommand DeleteCommand = new FbCommand("UPDATE ITEM SET CLIENT_IS_DELETE = 1 WHERE CLIENT_ID = @ClientID", fbCon); FbParameter ParamID = new FbParameter("@ClientID", FbDbType.VarChar); ParamID.Value = ClientID; DeleteCommand.Parameters.Add(ParamID); DeleteCommand.Transaction = myTransaction; DeleteCommand.ExecuteNonQuery(); myTransaction.Commit(); } fbCon.Close(); MovePicLogWriter.Close(); MovePicLog.Close(); }
private static void DropDatabase() { FbConnection.ClearAllPools(); var connectionStringBuilder = new FbConnectionStringBuilder(ConnectionUtils.GetConnectionString()); if (File.Exists(connectionStringBuilder.Database)) FbConnection.DropDatabase(connectionStringBuilder.ConnectionString); }
public static void CreateDatabase(string connectionString) { var connectionStringBuilder = new FbConnectionStringBuilder(connectionString); if (File.Exists(connectionStringBuilder.Database)) DropDatabase(connectionString); FbConnection.CreateDatabase(connectionString); }
public static string CreateConectionString(string databaseFile, string userName, string userPass, string _charset) { FbConnectionStringBuilder ConnectionSB = new FbConnectionStringBuilder(); ConnectionSB.Database = databaseFile; ConnectionSB.UserID = userName; ConnectionSB.Password = userPass; ConnectionSB.Charset = _charset; ConnectionSB.Pooling = false; return ConnectionSB.ToString(); }
public static String GetConnectionString(Database databaseSettings) { var connectionString = new FbConnectionStringBuilder(); connectionString.Database = databaseSettings.DatabaseFile; connectionString.DataSource = "localhost"; connectionString.Dialect = 3; connectionString.UserID = databaseSettings.User; connectionString.Password = databaseSettings.Password; connectionString.Charset = "WIN1251"; connectionString.ConnectionTimeout = 15; return connectionString.ToString(); }
/// <summary> /// Создает подключение к Firebird /// </summary> /// <returns>Подключение к Firebird</returns> public static FbConnection GetConnection() { var csb = new FbConnectionStringBuilder(); csb.DataSource = "localhost"; csb.Database = RemoteControl.Settings.Database.DatabaseFile; csb.UserID = RemoteControl.Settings.Database.User; csb.Password = RemoteControl.Settings.Database.Password; csb.Charset = "WIN1251"; csb.Dialect = 3; csb.ConnectionTimeout = 15; return new FbConnection(csb.ToString()); }
/// <summary> /// Возвращает строку для подключения к Firebird /// </summary> /// <param name="databaseParams">Параметры для подключения к Firebird</param> public String GetConnectionString(Database databaseParams) { // формируем строку для подключения FbConnectionStringBuilder cs = new FbConnectionStringBuilder(); cs.DataSource = "localhost"; cs.Database = databaseParams.DatabaseFile; cs.UserID = databaseParams.User; cs.Password = databaseParams.Password; cs.Charset = "WIN1251"; cs.Dialect = 3; cs.ConnectionTimeout = 15; return cs.ToString(); }
private static string GetConnectionString() { var cs = new FbConnectionStringBuilder { Database = "Data/database.fdb", UserID = "SYSDBA", Password = "******", Charset = "UTF8", ServerType = FbServerType.Embedded }; return cs.ToString(); }
/// <summary> /// Creates an instance of FbBatchExecution engine with the given /// connection. /// </summary> /// <param name="sqlConnection">A <see cref="FbConnection"/> object.</param> public FbBatchExecution(FbConnection sqlConnection) { if (sqlConnection == null) { this.sqlConnection = new FbConnection(); // do not specify the connection string this.connectionString = new FbConnectionStringBuilder(); } else { this.sqlConnection = sqlConnection; this.connectionString = new FbConnectionStringBuilder(sqlConnection.ConnectionString); } }
private string GetFb2ConnectionString() { var builder = new FbConnectionStringBuilder(); builder.DataSource = "localhost"; builder.Database = @"TestFb2.fdb"; builder.Charset = "UTF8"; builder.UserID = "SYSDBA"; builder.Password = "******"; builder.ServerType = FbServerType.Embedded; builder.ClientLibrary = @"fb25\fbembed"; builder.Pooling = false; return builder.ToString(); }
private static void RecreateDatabaseAndInstallObjects() { FbConnection.ClearAllPools(); var connectionStringBuilder = new FbConnectionStringBuilder(ConnectionUtils.GetConnectionString()); if (File.Exists(connectionStringBuilder.Database)) FbConnection.DropDatabase(connectionStringBuilder.ConnectionString); FbConnection.CreateDatabase(connectionStringBuilder.ToString(), 16384, true, false); using (var connection = new FbConnection(connectionStringBuilder.ToString())) { FirebirdObjectsInstaller.Install(connection); } }
public string BuildConnectionString() { FbConnectionStringBuilder cs = new FbConnectionStringBuilder(); cs.UserID = ConfigurationManager.AppSettings["User"]; cs.Password = ConfigurationManager.AppSettings["Password"]; cs.Database = ConfigurationManager.AppSettings["Database"]; cs.DataSource = ConfigurationManager.AppSettings["DataSource"]; cs.Port = Int32.Parse(ConfigurationManager.AppSettings["Port"]); cs.Charset = ConfigurationManager.AppSettings["Charset"]; cs.Pooling = false; cs.ServerType = (FbServerType)Int32.Parse(ConfigurationManager.AppSettings["ServerType"]); return cs.ToString(); }
public override FbConnection getConnection() { FbConnectionStringBuilder fbSb = new FbConnectionStringBuilder(); //fbSb.Charset = "WIN1251"; fbSb.UserID = Properties.Settings.Default.login; fbSb.Password = Properties.Settings.Default.password; fbSb.Port = 3050; fbSb.DataSource = Properties.Settings.Default.host; fbSb.Database = Properties.Settings.Default.dbname; fbSb.ServerType = 0; //fbSb.ConnectionTimeout = 30; //MessageBox.Show(fbSb.ToString()); FbConnection fb = new FbConnection(fbSb.ToString()); return fb; }
public bool CheckConnectionString(string constr) { try { var csbCheck = new FbConnectionStringBuilder(constr) {Pooling = false}; using (var con = new FbConnection(csbCheck.ConnectionString)) con.Open(); } catch { return false; } return true; }
static Backup() { FBDC.FbConnectionStringBuilder connectionInfo = new FBDC.FbConnectionStringBuilder(); SCLP.LogProxy.Log(SCLP.LogLevel.Info, "Backup Manager is now initializing..."); SCLP.LogProxy.Log(SCLP.LogLevel.Info, "Creating cache directories if necessary..."); cacheDirectory = new DirectoryInfo( SC.Configuration.SafemateRootPath + @"\Cache"); creationCacheDirectory = new DirectoryInfo( cacheDirectory.FullName + @"\Build"); backupOperations = new List <QueuedBackupOperation>(); backupService = new FBDS.FbBackup(); restorationService = new FBDS.FbRestore(); restorationPath = String.Format( "{0}\\{1}", creationCacheDirectory.FullName, "RestorationTesting.fdb"); restorationService.Options = FBDS.FbRestoreFlags.Replace; connectionInfo.Charset = "NONE"; connectionInfo.Database = restorationPath; connectionInfo.DataSource = "localhost"; connectionInfo.Password = "******"; connectionInfo.UserID = "sysdba"; restorationService.ConnectionString = connectionInfo.ToString(); backupService.Verbose = restorationService.Verbose = true; backupService.ServiceOutput += ServiceOutputHandler; restorationService.ServiceOutput += ServiceOutputHandler; #if __Safemate_Core_Backup_Debug fragmentThreshold = 1 << 30; #endif CreateCreationCache(); }
public DbTestFireBird() { FbConnectionStringBuilder builder = new FbConnectionStringBuilder { ServerType = FbServerType.Embedded, UserID = Login, Password = Password, Dialect = Dialect, Charset = Charset, ClientLibrary = PathToDll, Database = PathToDb }; pConnectionString = builder.ToString(); Random r = new Random(); pRandomString = r.NextDouble().ToString(); }
public SQL() { FbConnectionStringBuilder fb_con = new FbConnectionStringBuilder(); fb_con.Charset = "WIN1251"; //используемая кодировка fb_con.UserID = Program.DATALogin; //логин fb_con.Password = Program.DATAPass; //пароль if(Program.DATASource!="0") fb_con.DataSource = Program.DATASource; if (Program.DATAPort != "0") fb_con.Port = int.Parse(Program.DATAPort); fb_con.Database = Program.DATAserver; //путь к файлу базы данных fb_con.ServerType = 0; //указываем тип сервера (0 - "полноценный Firebird" (classic или super server), 1 - встроенный (embedded)) //создаем подключение fb = new FbConnection(fb_con.ToString()); //передаем нашу строку подключения объекту класса FbConnection }
public DrugstoreData() { FbConnectionStringBuilder csb = new FbConnectionStringBuilder(); // Путь до файла с базой данных csb.Database = "D:\\data\\DS.FDB"; // Настройка параметров "общения" клиента с сервером csb.Charset = "WIN1251"; csb.Dialect = 3; // Настройки аутентификации csb.UserID = "SYSDBA"; csb.Password = "******"; Connection = new FbConnection(csb.ToString()); }
private Database() { csBuilder = new FbConnectionStringBuilder(); csBuilder.Charset = "UTF8"; csBuilder.DataSource = "localhost"; csBuilder.Database = @"D:\AUTORUN_V1.1.fdb"; csBuilder.UserID = "SYSDBA"; csBuilder.Password = "******"; connection = new FbConnection(csBuilder.ConnectionString); platform = new PlatformTableAdapter(connection); category = new CategoryTableAdapter(connection); item = new ItemTableAdapter(connection); itemPlatform = new ItemPlatformTableAdapter(connection); }
private void ParseOld() { FbConnectionStringBuilder csb = new FbConnectionStringBuilder(); csb.UserID = "SYSDBA"; csb.Password = "******"; csb.Database = txtDatabaseFile.Text; csb.ServerType = FbServerType.Default; // embedded Firebird List<tabelldef> tabelldefs = new List<tabelldef>(); tabelldefs.Add(new tabelldef() { tableName = "BREVDB", idNum = 0, kliNum = 1, dokNum = 14 }); tabelldefs.Add(new tabelldef() { tableName = "JOURNALER", idNum = 0, kliNum = 4, dokNum = 10 }); tabelldefs.Add(new tabelldef() { tableName = "TEKSTBH", idNum = 0, dokNum = 5 }); FbConnection c = new FbConnection(csb.ToString()); c.Open(); foreach (tabelldef t in tabelldefs) { Application.DoEvents(); logg1.Refresh(); try { FbCommand cmd = new FbCommand("SELECT * FROM " + t.tableName, c); using (FbDataReader r = cmd.ExecuteReader()) { if (!Directory.Exists(Path.Combine(txtSavePath.Text, t.tableName))) Directory.CreateDirectory(Path.Combine(txtSavePath.Text, t.tableName)); while (r.Read()) { StreamWriter sw = File.CreateText(txtSavePath.Text + @"\" + t.tableName + @"\" + r.GetString(t.idNum) + (t.kliNum == -1 ? "" : "_" + r.GetString(t.kliNum)) + ".rtf"); sw.Write(r.GetString(t.dokNum)); sw.Close(); logg1.Log("Hentet ut " + t.tableName + " med id " + r.GetString(t.idNum) + Environment.NewLine, Logg.LogType.Info); Application.DoEvents(); logg1.Refresh(); } } } catch (Exception ex) { logg1.Log("Feil ved uthenting av " + t.tableName + ". Feilen var : " + ex.Message + Environment.NewLine, Logg.LogType.Info); } } //Console.ReadKey(); }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { var connectionString = new FB.FbConnectionStringBuilder( @"User=SYSDBA;Password=masterkey;Database=..\..\..\EFCoreSample.fdb;DataSource=localhost;Port=3050;") { //Dialect = 1 }.ConnectionString; optionsBuilder .UseFirebird(connectionString) .ConfigureWarnings(c => c.Log(CoreEventId.IncludeIgnoredWarning)); var loggerFactory = new LoggerFactory() .AddConsole() .AddDebug(); optionsBuilder.UseLoggerFactory(loggerFactory); }
public QueuedBackupOperation(String database, IEnumerable <FC.IFileRepository> targets) { SCLP.LogProxy.Log(SCLP.LogLevel.Info, database + " queued for backup."); this.database = new FileInfo(database); connectionString = new FBDC.FbConnectionStringBuilder(); validationDirectory = new DirectoryInfo( SCB.Backup.CreationCachePath); connectionString.Charset = "NONE"; connectionString.Database = database; connectionString.DataSource = "localhost"; connectionString.Password = "******"; connectionString.UserID = "sysdba"; this.targets = targets; }