当前位置: 首页>>代码示例>>C#>>正文


C# FbConnection.Open方法代码示例

本文整理汇总了C#中FirebirdSql.Data.FirebirdClient.FbConnection.Open方法的典型用法代码示例。如果您正苦于以下问题:C# FbConnection.Open方法的具体用法?C# FbConnection.Open怎么用?C# FbConnection.Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FirebirdSql.Data.FirebirdClient.FbConnection的用法示例。


在下文中一共展示了FbConnection.Open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateDatabase

#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
			}
		}
开发者ID:permyakov,项目名称:janus,代码行数:31,代码来源:FBSchemaDriver.cs

示例2: TestDatabaseConnection

 public static void TestDatabaseConnection(Object sender, TestDatabaseConnectionEventArgs e)
 {
     using (var connection = new FbConnection(GetConnectionString(e.DatabaseSettings)))
     {
         connection.Open();
     }
 }
开发者ID:Dennis-Petrov,项目名称:Cash,代码行数:7,代码来源:DatabaseHelper.cs

示例3: FbDatabase

 public FbDatabase(IContainerSettings settings)
 {
     var set = (FbDatabaseSettings)settings;
     _conw = new FbConnection(set.ConnectionString);
     try
     {
         _conw.Open();
         SwitchTrigger("MD5_LIST_FROM_EMPTY", UpdateEmptyList() > 0);
     }
     catch (FbException e)
     {
         if (e.ErrorCode == 335544344)
         {
             if (System.Windows.Forms.MessageBox.Show("File not exists" + (set.isEmbedded ? " or database is opened" : string.Empty) + ".\r\nTry to create file?", "Error", MessageBoxButtons.YesNo) == DialogResult.No)
                 throw;
             CreateDb(_conw.ConnectionString, Path.Combine(Helpers.AssemblyDirectory(Assembly.GetExecutingAssembly()), "struct.sql"));
             _conw.Open();
         }
         else
             throw;
     }
     if (_conw.State == System.Data.ConnectionState.Closed)
         _conw.Open();
     _CurrentSettings = (FbDatabaseSettings)set.Clone();
     _conr = new FbConnection(set.ConnectionString);
     _conr.Open();
     InitTagsLength();
     StoppedEvent.Set();
 }
开发者ID:xCMNx,项目名称:BooruViewer.Net,代码行数:29,代码来源:FBDatabase.cs

示例4: LoadAll

		override internal void LoadAll()
		{
			try
			{
				FbConnection cn = new FirebirdSql.Data.FirebirdClient.FbConnection(this._dbRoot.ConnectionString);
				cn.Open();
				string dbName = cn.Database;
				cn.Close();

				int index = dbName.LastIndexOfAny(new char[]{'\\'});

				if (index >= 0)
				{
					dbName = dbName.Substring(index + 1);
				}

				// We add our one and only Database
				FirebirdDatabase database = (FirebirdDatabase)this.dbRoot.ClassFactory.CreateDatabase();
				database._name = dbName;
				database.dbRoot = this.dbRoot;
				database.Databases = this;
				this._array.Add(database);
			}
			catch {}
		}
开发者ID:nguyenhuuhuy,项目名称:mygeneration,代码行数:25,代码来源:Databases.cs

示例5: abrir

 public static bool abrir()
 {
     conexao = new FbConnection(stringConexao);
     conexao.Open();
     transacao = conexao.BeginTransaction();
     return true;
 }
开发者ID:Artenes,项目名称:frogi-os,代码行数:7,代码来源:Conexao.cs

示例6: Main

        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 = "masterkey";
                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();
        }
开发者ID:kowill,项目名称:Sample,代码行数:25,代码来源:Program.cs

示例7: Conexao_Banco

        public Conexao_Banco(/*string _codigo*/)
        {
            InitializeComponent();

            aux_codigo = tx_pesquisa.Text;
            //this.aux_codigo = _codigo;
            /*string caminho = @"C:\Sistema de Registro da Producao Ambulatorial\FBCADASTRO_AGENDA.FDB";
            string conexao = "User=SYSDBA;"
                + "PassWord=masterkey;"
                + "DataBase=" + caminho;*/
            //DRIVER=Firebird/InterBase(r) driver;UID=SYSDBA;PWD=masterkey; DBNAME=MyServer/3051:C:\database\myData.fdb;
            // @"DataSource=localhost; Database=C:\PastaFireBird\BANCOFIREBIRD.FDB;";
            //User=SYSDBA; Password=masterkey; Database=D:\Meus Documentos\Faculdade - Esucri\Programação avançada I\Delphi com Banco\Banco\BANCO.FDB; DataSource=192.168.0.100;Dialect=3;PacketSize = 4096;"
            string conexao = @"User=SYSDBA;Password=masterkey;Database=C:\Sistema de Registro da Producao Ambulatorial\FBCADASTRO_AGENDA.FDB;DataSource=RECEPCAO;Port=3050;Dialect=3;PacketSize=4096";

            _fbConexao = new FbConnection(conexao);

            try
            {
                _fbConexao.Open();

            }
            catch (Exception erro)
            {

                MessageBox.Show(erro.ToString());
            }
            dtgrd_view.DataSource = _dtTable;
            _fbConexao.Close();
        }
开发者ID:ribeiroluis,项目名称:Listagem_ACS,代码行数:30,代码来源:Conexao_Banco.cs

示例8: Main

        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();
        }
开发者ID:kowill,项目名称:Sample,代码行数:60,代码来源:Program.cs

示例9: InsertTest

        public void InsertTest()
        {
            FbConnectionStringBuilder csb = base.BuildConnectionStringBuilder();

            csb.Enlist = true;

            using (TransactionScope scope = new TransactionScope())
            {
                using (FbConnection c = new FbConnection(csb.ToString()))
                {
                    c.Open();

                    string sql = "insert into TEST (int_field, date_field) values (1002, @date)";

                    using (FbCommand command = new FbCommand(sql, c))
                    {
                        command.Parameters.Add("@date", FbDbType.Date).Value = DateTime.Now.ToString();

                        int ra = command.ExecuteNonQuery();

                        Assert.AreEqual(ra, 1);
                    }
                }

                scope.Complete();
            }
        }
开发者ID:antgraf,项目名称:Embedded-DB-.Net-Performance-Test,代码行数:27,代码来源:TransactionScopeTests.cs

示例10: Add

        internal static void Add(MovieInfo movieInfo)
        {
            string commandText = @"INSERT INTO MOVIE_DATA (
                                    LOCATION, FILE_DATA_X, FILE_DATA_Y, FILE_DATA_DURATION, RAW_TITLE_PATH)
                                    VALUES (@location, @file_data_x, @file_data_y, @file_duration, @raw_title_path)";

            using (FbConnection connection = new FbConnection (string.Format (CONNECTION_STRING_FORMAT_FIREBIRD, DB_FILENAME)))
            {
                connection.Open ();

                using (FbTransaction transaction = connection.BeginTransaction ())
                {
                    using (FbCommand cmd = new FbCommand (commandText, connection, transaction))
                    {
                        cmd.Parameters.Add (new FbParameter ("@location", movieInfo.DvdName));
                        cmd.Parameters.Add (new FbParameter ("@file_data_x", movieInfo.FileData.X));
                        cmd.Parameters.Add (new FbParameter ("@file_data_y", movieInfo.FileData.Y));
                        cmd.Parameters.Add (new FbParameter ("@file_duration", movieInfo.FileData.Duration));
                        cmd.Parameters.Add (new FbParameter ("@raw_title_path", movieInfo.RawTitlePath));

                        cmd.ExecuteNonQuery ();
                    }
                    transaction.Commit ();
                }
            }
        }
开发者ID:AZiegler71,项目名称:DVD-Sammlung,代码行数:26,代码来源:MoviePersistence.cs

示例11: NomeArqCte

        private string NomeArqCte()
        {
            FbConnection con = null;
            try
            {
                string sNomeArq = "";
                FbCommand cmd = new FbCommand();
                con = new FbConnection(HlpDbFuncoesGeral.MontaStringConexao());
                cmd.Connection = con;
                con.Open();
                cmd.CommandText = "SP_CHAVEPRI";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Clear();

                cmd.Parameters.Add("@SNOMEGENERATOR", FbDbType.VarChar, 31).Value = "GEN_NOMEARQXML";

                sNomeArq = cmd.ExecuteScalar().ToString();

                return "Cte_" + sEmp + sNomeArq.PadLeft(15, '0') + ".xml";
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }

        }
开发者ID:dramosti,项目名称:GeraXml_3.0,代码行数:30,代码来源:belPopulaObjetos.cs

示例12: VerificaProprietario

        //1 - exclusivo 0 - compartilhado
        public static void VerificaProprietario(string nomeEntidade, FbConnection conn, ref bool empresa, ref bool filial)
        {
            ConfigurarDicionario();

            if(conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }

            using(FbCommand comando = conn.CreateCommand())
            {
                string nomeTabela = dicionario[nomeEntidade];

                comando.CommandText = "SELECT ACESSOEMPRESA, ACESSOFILIAL FROM SYS_TABLES WHERE ENTIDADE = @ENTIDADE";
                comando.Parameters.AddWithValue("@ENTIDADE", nomeTabela);

                using (FbDataReader leitor = comando.ExecuteReader())
                {
                    if (leitor.HasRows)
                    {
                        int indexEmpresa = leitor.GetOrdinal("ACESSOEMPRESA");
                        int indexFilial = leitor.GetOrdinal("ACESSOFILIAL");

                        while (leitor.Read())
                        {
                            empresa = Convert.ToBoolean(leitor.GetInt32(indexEmpresa));
                            filial = Convert.ToBoolean(leitor.GetInt32(indexFilial));
                        }   
                    }
                }
            }
        }
开发者ID:PablusVinii,项目名称:OrdemServico,代码行数:33,代码来源:ProprietarioEntidade.cs

示例13: GetJson

        private string GetJson(string CommandText, string ParentNodeName, params FbParameter[] pars)
        {
            FbConnectionStringBuilder connString = TeeboaConnection.ConnectionString;
            using (FbConnection conn = new FbConnection(connString.ToString()))
            {
                using (FbCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = CommandText;

                    for (int i = 0; i < pars.Length; i++)
                    {
                        cmd.Parameters.Add(pars[i]);
                    }
                    try
                    {
                        conn.Open();
                        using (FbDataReader dr = cmd.ExecuteReader())
                        {
                            return ParentNodeName == string.Empty ? stringify(dr) : stringify(dr, ParentNodeName);
                        }
                    }
                    catch (Exception ex)
                    {
                        return string.Format("Message: {1}{0}Method: {2}{0}", "<br />", ex.Message, ex.TargetSite);
                    }
                }
            }
        }
开发者ID:dotnetCarpenter,项目名称:teeboa,代码行数:29,代码来源:RoppongiMethods.cs

示例14: CreateTestTablesFb2

        private void CreateTestTablesFb2(string connectionString)
        {
            using (var con = new FbConnection(connectionString))
            using (var command = con.CreateCommand())
            {
                var sb = new StringBuilder();

                sb.Append("recreate table test(");
                sb.Append("int_test integer default 0 not null primary key,");
                sb.Append("bigint_test bigint,");
                sb.Append("blob_test blob,");
                sb.Append("char_test char(20),");
                sb.Append("date_test date,");
                sb.Append("decimal_test decimal,");
                sb.Append("double_test double precision,");
                sb.Append("float_test float,");
                sb.Append("numeric_test numeric,");
                sb.Append("smallint_test smallint,");
                sb.Append("time_test time,");
                sb.Append("timestamp_test timestamp,");
                sb.Append("varchar_test varchar(100)");
                sb.Append(")");

                command.CommandText = sb.ToString();
                con.Open();
                command.ExecuteNonQuery();
            }
        }
开发者ID:degarashi0913,项目名称:FAManagementStudio,代码行数:28,代码来源:ConnectionTestFb2.cs

示例15: RetornaNomeUsuarioCadastrado

        public DataTable RetornaNomeUsuarioCadastrado(string prontuario)
        {
            FbConnection conex = new FbConnection(conexao);

            string query = "SELECT * FROM TBUSUARIO WHERE CDUSUARIO = '"+prontuario+"'";
            FbCommand comando = new FbCommand(query, conex);
            try
            {

                conex.Open();

                FbDataAdapter datareader = new FbDataAdapter(comando);
                DataTable usuarios = new DataTable();
                datareader.Fill(usuarios);
                return usuarios;
            }
            catch (Exception err)
            {

                throw err;
            }
            finally
            {
                conex.Close();
            }
        }
开发者ID:ribeiroluis,项目名称:SIGHOMEROGIL,代码行数:26,代码来源:AcessoFireBird.cs


注:本文中的FirebirdSql.Data.FirebirdClient.FbConnection.Open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。