/// <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);
            }
        }
        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);
            }
        }
Exemple #3
0
 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);
     }
 }
Exemple #4
0
        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);
            }
        }
 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;
 }
Exemple #6
0
        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);
            }
        }
Exemple #7
0
        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);
                }
            }
        }
Exemple #8
0
        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();
        }
Exemple #9
0
 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();
 }
Exemple #10
0
 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>
 /// <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();
 }
        /// <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());
        }
Exemple #13
0
        private static string GetConnectionString()
        {
            var cs = new FbConnectionStringBuilder
                {
                    Database = "Data/database.fdb",
                    UserID = "SYSDBA",
                    Password = "******",
                    Charset = "UTF8",
                    ServerType = FbServerType.Embedded
                };

            return cs.ToString();
        }
        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();
        }
 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;
 }
Exemple #16
0
        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();
        }
Exemple #17
0
        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());
        }
Exemple #18
0
        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 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();
		}
        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();
        }
Exemple #21
0
        public FirebirdDatabase()
        {
            DbType = DatabaseType.Firebird;
            ProviderName = DatabaseType.Firebird.GetProviderName();
            DBPath = Environment.CurrentDirectory;

#if RUN_ALL_TESTS
            // Create one database for each test. Remember to delete after.
            DBPath = Path.Combine(Path.GetTempPath(), "NPoco", "Fb");
            if (!Directory.Exists(DBPath))
                Directory.CreateDirectory(DBPath);

            DBName = Guid.NewGuid().ToString();
#endif
            DBFileName = DBName + ".fdb";
            FQDBFile = DBPath + "\\" + DBFileName;

            // ConnectionString Builder
            FbConnectionStringBuilder csb = new FbConnectionStringBuilder();
            csb.Database = FQDBFile;
            csb.DataSource = "localhost";
            csb.Dialect = 3;
            csb.Charset = "UTF8";
            csb.Pooling = false;
            csb.Role = FbRole;
            csb.UserID = FbUserName; 
            csb.Password = FbUserPass; 

            ConnectionString = csb.ToString();

            RecreateDataBase();
            EnsureSharedConnectionConfigured();

            Console.WriteLine("Tables (Constructor): " + Environment.NewLine);
            var dt = ((FbConnection)Connection).GetSchema("Tables", new[] { null, null, null, "TABLE" });
            foreach (DataRow row in dt.Rows)
            {
                Console.WriteLine((string)row[2]);
            }
        }
Exemple #22
0
        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();
        }
Exemple #23
0
        public string BuildServicesConnectionString(bool includeDatabase)
        {
            FbConnectionStringBuilder cs = new FbConnectionStringBuilder();

            cs.DataSource   = ConfigurationManager.AppSettings["DataSource"];
            cs.UserID       = ConfigurationManager.AppSettings["User"];
            cs.Password     = ConfigurationManager.AppSettings["Password"];
            if (includeDatabase)
            {
                cs.Database = ConfigurationManager.AppSettings["Database"];
            }
            cs.ServerType   = (FbServerType)Convert.ToInt32(ConfigurationManager.AppSettings["ServerType"]);

            return cs.ToString();
        }
Exemple #24
0
        public override void RecreateDataBase()
        {
            // ConnectionString Builder
            FbConnectionStringBuilder csb = new FbConnectionStringBuilder();
            csb.DataSource = "localhost";
            csb.Dialect = 3;
            csb.Charset = "UTF8";
            csb.Pooling = false;
            csb.UserID = "SYSDBA"; // default user
            csb.Password = "******"; // default password

            string serverConnectionString = csb.ToString();
            csb.Database = csb.Database = FQDBFile;

            string databaseConnectionString = csb.ToString();

            Console.WriteLine("-------------------------");
            Console.WriteLine("Using Firebird Database  ");
            Console.WriteLine("-------------------------");

            base.RecreateDataBase();

            // Create simple user
            FbSecurity security = new FbSecurity();
            security.ConnectionString = serverConnectionString;
            var userData = security.DisplayUser(FbUserName);
            if (userData == null)
            {
                userData = new FbUserData();
                userData.UserName = FbUserName;
                userData.UserPassword = FbUserPass;
                security.AddUser(userData);
            }

            // Try to shutdown & delete database
            if (File.Exists(FQDBFile))
            {
                FbConfiguration configuration = new FbConfiguration();
                configuration.ConnectionString = databaseConnectionString;
                try
                {
                    configuration.DatabaseShutdown(FbShutdownMode.Forced, 0);
                    Thread.Sleep(1000);
                }
                finally
                {
                    File.Delete(FQDBFile);
                }
            }

            // Create the new DB
            FbConnection.CreateDatabase(databaseConnectionString, 4096, true, true);
            if (!File.Exists(FQDBFile)) throw new Exception("Database failed to create");

            // Create the Schema
            string script = @"
CREATE TABLE Users(
    UserId integer PRIMARY KEY NOT NULL, 
    Name varchar(200), 
    Age integer, 
    DateOfBirth timestamp, 
    Savings decimal(10,5),
    Is_Male smallint,
    UniqueId char(38),
    TimeSpan time,
    TestEnum varchar(10),
    HouseId integer,
    SupervisorId integer
                );
          
CREATE TABLE ExtraUserInfos(
    ExtraUserInfoId integer PRIMARY KEY NOT NULL, 
    UserId integer NOT NULL, 
    Email varchar(200), 
    Children integer 
);

CREATE TABLE Houses(
    HouseId integer PRIMARY KEY NOT NULL, 
    Address varchar(200)
);

CREATE TABLE CompositeObjects(
    Key1ID integer PRIMARY KEY NOT NULL, 
    Key2ID integer NOT NULL, 
    Key3ID integer NOT NULL, 
    TextData varchar(512), 
    DateEntered timestamp NOT NULL,
    DateUpdated timestamp  
);

CREATE GENERATOR USERS_USERID_GEN;
CREATE GENERATOR EXTRAUSERINFOS_ID_GEN;
CREATE GENERATOR HOUSES_HOUSEID_GEN;

SET TERM ^ ;

CREATE TRIGGER BI_USERS_USERID FOR USERS
ACTIVE BEFORE INSERT
POSITION 0
AS
BEGIN
  IF (NEW.USERID IS NULL) THEN
      NEW.USERID = GEN_ID(USERS_USERID_GEN, 1);
END^


CREATE TRIGGER BI_EXTRAUSERINFOS_ID1 FOR EXTRAUSERINFOS
ACTIVE BEFORE INSERT
POSITION 0
AS
BEGIN
  IF (NEW.EXTRAUSERINFOID IS NULL) THEN
      NEW.EXTRAUSERINFOID = GEN_ID(EXTRAUSERINFOS_ID_GEN, 1);
END^

CREATE TRIGGER BI_HOUSES_HOUSEID FOR HOUSES
ACTIVE BEFORE INSERT
POSITION 0
AS
BEGIN
  IF (NEW.HOUSEID IS NULL) THEN
      NEW.HOUSEID = GEN_ID(HOUSES_HOUSEID_GEN, 1);
END^

SET TERM ; ^

CREATE ROLE %role%;

GRANT SELECT, UPDATE, INSERT, DELETE ON Users TO ROLE %role%;
GRANT SELECT, UPDATE, INSERT, DELETE ON ExtraUserInfos TO ROLE %role%;
GRANT SELECT, UPDATE, INSERT, DELETE ON Houses TO ROLE %role%;
GRANT SELECT, UPDATE, INSERT, DELETE ON CompositeObjects TO ROLE %role%;

GRANT %role% TO %user%;
".Replace("%role%", FbRole).Replace("%user%", FbUserName);

/* 
 * Using new connection so that when a transaction is bound to Connection if it rolls back 
 * it doesn't blow away the tables
 */

            using (var conn = new FbConnection(databaseConnectionString))
            {
                FbScript fbScript = new FbScript(script);
                fbScript.Parse();
                FbBatchExecution fbBatch = new FbBatchExecution(conn, fbScript);
                fbBatch.Execute(true);

                conn.Open();
                Console.WriteLine("Tables (CreateDB): " + Environment.NewLine);
                var dt = conn.GetSchema("Tables", new[] {null, null, null, "TABLE"});
                foreach (DataRow row in dt.Rows)
                {
                    Console.WriteLine(row[2]);
                }

                conn.Close();
            }
        }
Exemple #25
0
        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;
            if ("all".Equals(options.Item))
            {
                ItemsCommand = new FbCommand("SELECT * FROM ITEM WHERE NUM_IID IS NULL AND CLIENT_NAVIGATION_TYPE = 1 OR SYNC_STATUS <> 1", fbCon);
            }
            else
            {
                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())
            {
                Boolean mainallpass = true;
                Boolean descallpass = true;
                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);

                if ("main".Equals(options.Scope) || "all".Equals(options.Scope))
                {
                    FbCommand PicturesCommand = new FbCommand("SELECT * FROM PICTURE WHERE CLIENT_ITEMID = @ClientItemID", fbCon);
                    FbParameter ParamClientID = new FbParameter("@ClientItemID", FbDbType.VarChar);
                    ParamClientID.Value = ClientID;
                    PicturesCommand.Parameters.Add(ParamClientID);
                    FbDataReader PicturesReader = PicturesCommand.ExecuteReader();
                    while (PicturesReader.Read())
                    {
                        MovePicLogWriter.WriteLine("----------");
                        Console.WriteLine("----------");
                        string PicClientID = PicturesReader["CLIENT_ID"].ToString();
                        string Url = PicturesReader["URL"].ToString();
                        string ClientName = PicturesReader["CLIENT_NAME"].ToString();
                        Console.WriteLine("URL=" + Url);
                        MovePicLogWriter.WriteLine("URL=" + Url);
                        Console.WriteLine("图片本地ID=" + PicClientID);
                        MovePicLogWriter.WriteLine("图片本地ID=" + PicClientID);
                        Console.WriteLine("CLIENT_NAME=" + ClientName);
                        MovePicLogWriter.WriteLine("CLIENT_NAME=" + ClientName);

                        if ("reupload".Equals(options.Action))
                        {
                            if (Url != null && !Url.Equals(""))
                            {
                                List<Picture> pictures = ImagesUtil.getPictures(Url, AppKey, AppSecret, SessionKey, MovePicLogWriter);
                                if (pictures != null && pictures.Count > 0)
                                {
                                    foreach (Picture picture in pictures)
                                    {
                                        Console.WriteLine(picture.PicturePath);
                                        MovePicLogWriter.WriteLine(picture.PicturePath);
                                        if (!picture.Status.Equals("pass"))
                                        {
                                            mainallpass = false;
                                            Console.WriteLine("审核中");
                                            MovePicLogWriter.WriteLine("审核中");
                                            DateTime dt = Convert.ToDateTime(picture.Modified);
                                            if (dt < DateTime.Now.AddDays(-3))
                                            {
                                                Console.WriteLine("过了3天重新上传");
                                                MovePicLogWriter.WriteLine("过了3天重新上传");
                                                ImagesUtil.reUploadImage(picture, AppKey, AppSecret, SessionKey, MovePicLogWriter);
                                            }
                                            else
                                            {
                                                Console.WriteLine("没有到3天再等一等");
                                                MovePicLogWriter.WriteLine("没有到3天再等一等");
                                            }
                                        }
                                        else
                                        {
                                            Console.WriteLine("排查通过");
                                            MovePicLogWriter.WriteLine("排查通过");
                                        }
                                    }
                                }
                                else
                                {
                                    mainallpass = false;
                                    Console.WriteLine("图片不在图片空间 " + Url);
                                    MovePicLogWriter.WriteLine("图片不在图片空间 " + Url);
                                    string PicPath = ImagesUtil.uploadImage(Url, AppKey, AppSecret, SessionKey, MovePicLogWriter);
                                    if (!PicPath.Equals(""))
                                    {
                                        FbTransaction myTransaction = fbCon.BeginTransaction();
                                        Console.WriteLine("PicPath=" + PicPath);
                                        MovePicLogWriter.WriteLine("PicPath=" + PicPath);
                                        FbCommand UpdateUrlCommand = new FbCommand("UPDATE PICTURE SET URL = @Url WHERE CLIENT_ID = @ClientID", fbCon);
                                        FbParameter ParamUrl = new FbParameter("@Url", FbDbType.VarChar);
                                        ParamUrl.Value = PicPath;
                                        FbParameter ParamID = new FbParameter("@ClientID", FbDbType.VarChar);
                                        ParamID.Value = PicClientID;
                                        UpdateUrlCommand.Parameters.Add(ParamUrl);
                                        UpdateUrlCommand.Parameters.Add(ParamID);
                                        UpdateUrlCommand.Transaction = myTransaction;
                                        UpdateUrlCommand.ExecuteNonQuery();
                                        myTransaction.Commit();
                                        MovePicLogWriter.WriteLine(Url + " 被替换为\n" + PicPath);
                                        Console.WriteLine(Url + " 被替换为\n" + PicPath);
                                        Console.WriteLine("上传完成");
                                        MovePicLogWriter.WriteLine("上传完成");
                                    }
                                }

                            }
                        }
                    }
                }
                if ("desc".Equals(options.Scope) || "all".Equals(options.Scope))
                {
                    ArrayList images = new ArrayList();
                    string Desc = ItemsReader["DESCRIPTION"].ToString();
                    string imgpattern = "http://[^\\s]*?((\\.jpg)|(\\.png)|(\\.gif)|(\\.bmp))";
                    Regex r = new Regex(imgpattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
                    Match m = r.Match(Desc);
                    while (m.Success)
                    {
                        System.Text.RegularExpressions.Group imageGroup = m.Groups[0];
                        images.Add(imageGroup.Value);
                        m = m.NextMatch();
                    }
                    foreach (string image in images)
                    {
                        MovePicLogWriter.WriteLine("----------");
                        Console.WriteLine("----------");
                        Console.WriteLine(image);
                        MovePicLogWriter.WriteLine(image);
                        if ("reupload".Equals(options.Action))
                        {
                            Console.WriteLine("检查图片状态");
                            MovePicLogWriter.WriteLine("检查图片状态");
                            List<Picture> pictures = ImagesUtil.getPictures(image, AppKey, AppSecret, SessionKey, MovePicLogWriter);
                            if (pictures != null && pictures.Count > 0)
                            {
                                foreach (Picture picture in pictures)
                                {
                                    Console.WriteLine(picture.PicturePath);
                                    MovePicLogWriter.WriteLine(picture.PicturePath);
                                    if (!picture.Status.Equals("pass"))
                                    {
                                        descallpass = false;
                                        Console.WriteLine("审核中");
                                        MovePicLogWriter.WriteLine("审核中");
                                        DateTime dt = Convert.ToDateTime(picture.Modified);
                                        if (dt < DateTime.Now.AddDays(-3))
                                        {
                                            Console.WriteLine("过了3天重新上传");
                                            MovePicLogWriter.WriteLine("过了3天重新上传");
                                            bool done = ImagesUtil.reUploadImage(picture, AppKey, AppSecret, SessionKey, MovePicLogWriter);
                                            if (!done)
                                            {
                                                if (options.Prune)
                                                {
                                                    Desc = Desc.Replace(picture.PicturePath, "");
                                                }
                                            }
                                        }
                                        else
                                        {
                                            Console.WriteLine("没有到3天再等一等");
                                            MovePicLogWriter.WriteLine("没有到3天再等一等");
                                        }
                                    }
                                    else
                                    {
                                        Console.WriteLine("排查通过");
                                        MovePicLogWriter.WriteLine("排查通过");
                                    }
                                }

                            }
                            else
                            {
                                descallpass = false;
                                Console.WriteLine("图片不在图片空间");
                                MovePicLogWriter.WriteLine("图片不在图片空间");
                                string PicPath = ImagesUtil.uploadImage(image, AppKey, AppSecret, SessionKey, MovePicLogWriter);
                                if (PicPath.Equals(""))
                                {
                                    if (options.Prune)
                                    {
                                        Desc = Desc.Replace(image, PicPath);
                                    }
                                }
                                else
                                {
                                    Desc = Desc.Replace(image, PicPath);
                                }
                            }
                        }
                    }

                    ArrayList localImages = new ArrayList();
                    string localImgPattern = @"[a-zA-Z]{1}\:[\\/][^\s]*?((\.jpg)|(\.png)|(\.gif)|(\.bmp))";
                    Regex r2 = new Regex(localImgPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
                    Match m2 = r2.Match(Desc);
                    while (m2.Success)
                    {
                        System.Text.RegularExpressions.Group imageGroup = m2.Groups[0];
                        localImages.Add(imageGroup.Value);
                        m2 = m2.NextMatch();
                    }
                    foreach (string localImage in localImages)
                    {
                        MovePicLogWriter.WriteLine("----------");
                        Console.WriteLine("----------");
                        string PicPath = "";
                        if (System.IO.File.Exists(localImage))
                        {
                            PicPath = ImagesUtil.uploadLocalImage(localImage, AppKey, AppSecret, SessionKey, MovePicLogWriter);
                        }
                        else
                        {
                            MovePicLogWriter.WriteLine(localImage + " 不存在。");
                            Console.WriteLine(localImage + " 不存在。");
                        }
                        if (PicPath.Equals(""))
                        {
                            if (options.Prune)
                            {
                                Desc = Desc.Replace(localImage, PicPath);
                            }
                        }
                        else
                        {
                            Desc = Desc.Replace(localImage, PicPath);
                        }

                    }

                    FbTransaction myTransaction = fbCon.BeginTransaction();
                    FbCommand UpdateDescCommand = new FbCommand("UPDATE ITEM SET DESCRIPTION = @Desc WHERE CLIENT_ID = @ClientID", fbCon);
                    FbParameter ParamID = new FbParameter("@ClientID", FbDbType.VarChar);
                    ParamID.Value = ClientID;
                    FbParameter ParamDesc = new FbParameter("@Desc", FbDbType.Text);
                    ParamDesc.Value = Desc;
                    UpdateDescCommand.Parameters.Add(ParamID);
                    UpdateDescCommand.Parameters.Add(ParamDesc);
                    UpdateDescCommand.Transaction = myTransaction;
                    UpdateDescCommand.ExecuteNonQuery();
                    myTransaction.Commit();
                }
                if (mainallpass && descallpass)
                {
                    FbTransaction myTransaction = fbCon.BeginTransaction();
                    FbCommand UpdateSyncStatusCommand = new FbCommand("UPDATE ITEM SET SYNC_STATUS = 2, UPLOAD_FAIL_MSG ='所有图片审核通过,可以上传了。' WHERE CLIENT_ID = @ClientID", fbCon);
                    FbParameter ParamID = new FbParameter("@ClientID", FbDbType.VarChar);
                    ParamID.Value = ClientID;
                    UpdateSyncStatusCommand.Parameters.Add(ParamID);
                    UpdateSyncStatusCommand.Transaction = myTransaction;
                    UpdateSyncStatusCommand.ExecuteNonQuery();
                    myTransaction.Commit();
                    Console.WriteLine("所有图片审核通过");
                    MovePicLogWriter.WriteLine("所有图片审核通过");
                }
                else
                {
                    FbTransaction myTransaction = fbCon.BeginTransaction();
                    FbCommand UpdateSyncStatusCommand = new FbCommand("UPDATE ITEM SET SYNC_STATUS = 4, UPLOAD_FAIL_MSG ='有图片等待审核。' WHERE CLIENT_ID = @ClientID", fbCon);
                    FbParameter ParamID = new FbParameter("@ClientID", FbDbType.VarChar);
                    ParamID.Value = ClientID;
                    UpdateSyncStatusCommand.Parameters.Add(ParamID);
                    UpdateSyncStatusCommand.Transaction = myTransaction;
                    UpdateSyncStatusCommand.ExecuteNonQuery();
                    myTransaction.Commit();
                    Console.WriteLine("==========>图片审核中");
                    MovePicLogWriter.WriteLine("==========>图片审核中");
                }
                Console.WriteLine("");
                MovePicLogWriter.WriteLine("");
            }

            fbCon.Close();
            MovePicLogWriter.Close();
            MovePicLog.Close();
        }
 /// <summary>
 /// Constructor for talking to an embedded firebird database.
 /// </summary>
 /// <param name="databasePath">Path to the db file.</param>
 public FirebirdDescriptor(string databasePath)
 {
     if (!StringHelper.IsNonBlank(databasePath))
     {
         throw new ArgumentNullException("databasePath", "Database file path cannot be null/blank.");
     }
     FbConnectionStringBuilder builder = new FbConnectionStringBuilder();
     builder.Database = Database = databasePath;
     builder.ServerType = FbServerType.Embedded;
     // For the embedded server, we want to disable pooling so we don't wind up locking
     // the file indefinitely.
     builder.Pooling = false;
     _usePooling = false;
     // There is no password, so the strings are the same.
     _cleanConnStr = builder.ToString();
     _connectionStr = builder.ToString();
 }
        /// <summary>
        /// Constructor for talking to a server-based firebird database.
        /// </summary>
        /// <param name="server">Server name or IP.  May not be null.</param>
        /// <param name="database">Database name on that server.  May not be null.</param>
        /// <param name="user">Database user name, may be null.</param>
        /// <param name="password">Plain text password for the user.
        ///                        May be null.</param>
        public FirebirdDescriptor(string server, string database,
            string user, string password)
        {
            if (!StringHelper.IsNonBlank(server))
            {
                throw new ArgumentNullException("server", "Server parameter cannot be null/blank.");
            }
            if (!StringHelper.IsNonBlank(database))
            {
                throw new ArgumentNullException("database", "Database name parameter cannot be null/blank.");
            }
            FbConnectionStringBuilder builder = new FbConnectionStringBuilder();
            builder.DataSource = Server = server;
            builder.Database = Database = database;
            builder.UserID = User = user;

            // First make it without a password.
            _cleanConnStr = builder.ToString();
            // Now with the password for the real one.
            Password = password;
            builder.Password = Password;
            _connectionStr = builder.ToString();
        }
        public override void ChangeDatabase(string db)
        {
#if (!NET_CF)
            lock (this)
            {
				this.CheckClosed();

                if (string.IsNullOrEmpty(db))
                {
                    throw new InvalidOperationException("Database name is not valid.");
                }

                string cs = this.connectionString;

                try
                {
                    FbConnectionStringBuilder csb = new FbConnectionStringBuilder(this.connectionString);

                    /* Close current connection	*/
                    this.Close();

                    /* Set up the new Database	*/
                    csb.Database = db;
                    this.ConnectionString = csb.ToString();

                    /* Open	new	connection	*/
                    this.Open();
                }
                catch (IscException ex)
                {
                    this.ConnectionString = cs;
                    throw new FbException(ex.Message, ex);
                }
            }
#endif
        }
Exemple #29
0
 private void btnSync_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 SESSIONS.ID FROM SESSIONS", cn);
                 FbDataAdapter da = new FbDataAdapter(cmd);
                 DataTable tbl = new DataTable();
                 da.Fill(tbl);
                 string query = "";
                 using (FbCommand cmd_o = new FbCommand())
                 {
                     cmd_o.Connection = cn;
                     cmd_o.CommandTimeout = 9000;
                     query = "CREATE TABLE SESSIONS_OK (ID INTEGER);";
                     cmd_o.CommandText = query;
                     try
                     {
                         cmd_o.ExecuteNonQuery();
                     }
                     catch { }
                     query = "DELETE FROM SESSIONS_OK;\n";
                     cmd_o.CommandText = query;
                     cmd_o.ExecuteNonQuery();
                     for (int i = 0; i < tbl.Rows.Count; i++)
                     {
                         query = "INSERT INTO SESSIONS_OK\n" +
                                         "\t(SESSIONS_OK.ID)\n" +
                                         "\tVALUES \n" +
                                         "\t(" + tbl.Rows[i]["ID"].ToString() + ");\n";
                         cmd_o.CommandText = query;
                         cmd_o.ExecuteNonQuery();
                     }
                 }
                 MessageBox.Show("ok");
             }
         }
         else
         {
             MessageBox.Show("Не верный формат строки!");
         }
     }
     catch(Exception ex)
     {
         MessageBox.Show(ex.Message + "\n" + ex.Source);
     }
 }
Exemple #30
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                return;
            }
            string SELLER_NICK = args[0];
            INIManager IniManager = new INIManager(Environment.CurrentDirectory + "\\" + "TradeAsist.ini");
            string TaobaoAsistantPath = IniManager.IniReadValue("淘宝助理", "路径");
            if (!TaobaoAsistantPath.Substring(TaobaoAsistantPath.Length - 1).Equals("\\"))
            {
                TaobaoAsistantPath = TaobaoAsistantPath + "\\";
            }
            Console.WriteLine(TaobaoAsistantPath);

            string WDGJ_IP = IniManager.IniReadValue("管家数据库", "IP");
            string WDGJ_USER = IniManager.IniReadValue("管家数据库", "USER");
            string WDGJ_PASSWORD = IniManager.IniReadValue("管家数据库", "PASSWORD");
            string WDGJ_DATABASE = IniManager.IniReadValue("管家数据库", "DATABASE");

            FbConnectionStringBuilder cs = new FbConnectionStringBuilder();
            cs.Database = TaobaoAsistantPath + "users\\" + SELLER_NICK + "\\APPTRADE.DAT";
            cs.UserID = "SYSDBA";
            cs.Password = "******";
            cs.ServerType = FbServerType.Embedded;
            FbConnection fbCon = new FbConnection(cs.ToString());
            fbCon.Open();
            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
            builder["server"] = WDGJ_IP;
            builder["uid"] = WDGJ_USER;
            builder["pwd"] = WDGJ_PASSWORD;
            builder["database"] = WDGJ_DATABASE;
            string sqlConnectionString = builder.ToString();
            SqlConnection sqlCon1 = new SqlConnection(sqlConnectionString);
            sqlCon1.Open();
            SqlConnection sqlCon2 = new SqlConnection(sqlConnectionString);
            sqlCon2.Open();

            SqlCommand cmd = new SqlCommand("SELECT * FROM G_TRADE_TRADELIST WHERE TRADESTATUS = 2", sqlCon1);
            SqlDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                string TradeID = reader["TradeID"].ToString();
                string TradeNO2 = reader["TradeNO2"].ToString();
                if (TradeNO2 == null || TradeNO2.Equals(""))
                {
                    continue;
                }
                string[] tradeNO = TradeNO2.Split(',');
                TradeNO2 = tradeNO[0];
                string TradeNick = reader["TradeNick"].ToString();
                string SndTo = reader["SndTo"].ToString();
                string Adr = reader["Adr"].ToString();
                string Tel = reader["Tel"].ToString();
                string sqlTrade = "SELECT * FROM TRADE WHERE TID = " + TradeNO2;

                FbCommand cmdTrade = new FbCommand(sqlTrade, fbCon);
                FbDataReader fbReader = cmdTrade.ExecuteReader();
                if (fbReader.Read())
                {

                    string TID = fbReader["TID"].ToString();
                    string BUYER_NICK = fbReader["BUYER_NICK"].ToString();
                    string RECEIVER_NAME = fbReader["RECEIVER_NAME"].ToString();
                    string RECEIVER_STATE = fbReader["RECEIVER_STATE"].ToString();
                    string RECEIVER_CITY = fbReader["RECEIVER_CITY"].ToString();
                    string RECEIVER_DISTRICT = fbReader["RECEIVER_DISTRICT"].ToString();
                    string RECEIVER_ADDRESS = fbReader["RECEIVER_ADDRESS"].ToString();
                    string RECEIVER_MOBILE = fbReader["RECEIVER_MOBILE"].ToString();
                    string RECEIVER_PHONE = fbReader["RECEIVER_PHONE"].ToString();

                    Console.WriteLine(TID + " " + BUYER_NICK + " " + RECEIVER_NAME + " " + RECEIVER_STATE + " " + RECEIVER_CITY + " " + RECEIVER_DISTRICT + " " + RECEIVER_ADDRESS + " " + RECEIVER_MOBILE + " " + RECEIVER_PHONE);
                    Console.WriteLine();
                    string updateAdrSql = "UPDATE G_TRADE_TRADELIST SET SndTo = @SndTo, Adr = @Adr, Tel = @Tel WHERE TradeID = " + TradeID;
                    SqlParameter paraSndTo = new SqlParameter("@SndTo", SqlDbType.NVarChar);
                    paraSndTo.Value = RECEIVER_NAME;
                    SqlParameter paraAdr = new SqlParameter("@Adr", SqlDbType.NVarChar);
                    paraAdr.Value = RECEIVER_STATE + " " + RECEIVER_CITY + " " + RECEIVER_DISTRICT + " " + RECEIVER_ADDRESS;
                    SqlParameter paraTel = new SqlParameter("@Tel", SqlDbType.NVarChar);
                    paraTel.Value = RECEIVER_MOBILE + " " + RECEIVER_PHONE;
                    SqlTransaction transaction = sqlCon2.BeginTransaction();
                    SqlCommand updateAdr = new SqlCommand(updateAdrSql, sqlCon2);
                    updateAdr.Parameters.Add(paraSndTo);
                    updateAdr.Parameters.Add(paraAdr);
                    updateAdr.Parameters.Add(paraTel);
                    updateAdr.Transaction = transaction;
                    updateAdr.ExecuteNonQuery();
                    transaction.Commit();
                }
            }
            sqlCon1.Close();
            sqlCon2.Close();
            fbCon.Close();
        }
        public void FbConnectionStringBuilderTest()
        {
            FbConnectionStringBuilder cs = new FbConnectionStringBuilder();

            cs.DataSource = ConfigurationManager.AppSettings["DataSource"];
            cs.Database = ConfigurationManager.AppSettings["Database"];
            cs.Port = Convert.ToInt32(ConfigurationManager.AppSettings["Port"]);
            cs.UserID = ConfigurationManager.AppSettings["User"];
            cs.Password = ConfigurationManager.AppSettings["Password"];
            cs.ServerType = (FbServerType)Convert.ToInt32(ConfigurationManager.AppSettings["ServerType"]);
            cs.Charset = ConfigurationManager.AppSettings["Charset"];
            cs.Pooling = Convert.ToBoolean(ConfigurationManager.AppSettings["Pooling"]);

            using (FbConnection c = new FbConnection(cs.ToString()))
            {
                c.Open();
            }
        }
        public void FbConnectionStringBuilderTest()
        {
            FbConnectionStringBuilder cs = new FbConnectionStringBuilder();

            cs.DataSource = TestsSetup.DataSource;
            cs.Database = TestsSetup.Database;
            cs.Port = TestsSetup.Port;
            cs.UserID = TestsSetup.UserID;
            cs.Password = TestsSetup.Password;
            cs.ServerType = this.FbServerType;
            cs.Charset = TestsSetup.Charset;
            cs.Pooling = TestsSetup.Pooling;

            Assert.DoesNotThrow(() =>
            {
                using (FbConnection c = new FbConnection(cs.ToString()))
                {
                    c.Open();
                }
            });
        }
		public static string BuildServicesConnectionString(FbServerType serverType, bool includeDatabase)
		{
			FbConnectionStringBuilder cs = new FbConnectionStringBuilder();

			cs.UserID = TestsSetup.UserID;
			cs.Password = TestsSetup.Password;
			cs.DataSource = TestsSetup.DataSource;
			if (includeDatabase)
			{
				cs.Database = TestsSetup.Database;
			}
			cs.ServerType = serverType;

			return cs.ToString();
		}
        /// <summary>
        /// This constructor reads all the appropriate values from our standard config file
        /// in the normal format.
        /// </summary>
        /// <param name="config">Config to get params from.</param>
        /// <param name="component">Section of the config XML to look in for db params.</param>
        /// <param name="decryptionDelegate">Delegate to call to decrypt password fields.
        ///                                  May be null if passwords are in plain text.</param>
        public FirebirdDescriptor(Config config, string component,
            ConnectionInfoDecryptionDelegate decryptionDelegate)
        {
            FbConnectionStringBuilder builder = new FbConnectionStringBuilder();
            Server = config.GetParameter(component, "Server", null);
            if (StringHelper.IsNonBlank(Server))
            {
                builder.DataSource = Server;
            }
            else
            {
                builder.ServerType = FbServerType.Embedded;
                // For the embedded server, we want to disable pooling so we don't wind up locking
                // the file indefinitely.
                builder.Pooling = false;
                _usePooling = false;
            }
            builder.Database = Database = config.GetParameterWithSubstitution(component, "Database", true);
            builder.UserID = User = config.GetParameter(component, "User", null);

            // First make it without a password.
            _cleanConnStr = builder.ToString();
            // Now with the password for the real one.
            Password = GetDecryptedConfigParameter(config, component, "Password", decryptionDelegate);
            builder.Password = Password;
            _connectionStr = builder.ToString();
        }