• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# FirebirdClient.FbConnection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



FbConnection类属于FirebirdSql.Data.FirebirdClient命名空间,在下文中一共展示了FbConnection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: Select

        public IModel Select(FbConnection conn, FbTransaction trans, string code)
        {
            string query = "SELECT * FROM models WHERE modelcode = UPPER(@modelcode)";

            IModel ret = null;

            try
            {
                using (FbCommand cmd = new FbCommand(query, conn, trans))
                {
                    cmd.Parameters.AddWithValue("modelcode", code.ToUpper());
                    using (FbDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            ret = new Model
                            {
                                Id = reader.GetInt32(0),
                                Code = reader.GetString(1),
                                ObjectIdRoot = reader.GetInt32(2)
                            };
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("Ошибка SQL запроса. {0}", ex.Message));
            }

            return ret;
        }
开发者ID:kindprojects,项目名称:workstation,代码行数:32,代码来源:RepModel.cs


示例4: CancelarNFseSistema

        public void CancelarNFseSistema(string sNumNfse, FbConnection Conn)
        {
            try
            {
                StringBuilder sSql = new StringBuilder();
                sSql.Append("update nf ");
                sSql.Append("set cd_recibocanc = '");
                sSql.Append("CANCELADA");
                sSql.Append("' ");
                sSql.Append("where ");
                sSql.Append("cd_empresa = '");
                sSql.Append(belStatic.codEmpresaNFe);
                sSql.Append("' ");
                sSql.Append("and ");
                sSql.Append("cd_numero_nfse = '");
                sSql.Append(sNumNfse);
                sSql.Append("'");
                using (FbCommand cmdUpdate = new FbCommand(sSql.ToString(), Conn))
                {
                    cmdUpdate.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                throw;
            }

        }
开发者ID:dramosti,项目名称:GeraXml_2.0,代码行数:28,代码来源:daoCancelamento.cs


示例5: GetDomain

 public IEnumerable<DomainInfo> GetDomain(FbConnection con)
 {
     using (var command = con.CreateCommand())
     {
         command.CommandText =
              $"select distinct f.rdb$field_type Type, f.rdb$field_sub_type SubType , f.rdb$character_length CharSize, trim(f.rdb$field_name) FieldName, f.rdb$field_precision FieldPrecision, f.rdb$field_scale FieldScale, f.rdb$field_length FieldLength, coalesce(f.rdb$validation_source, '') ValidationSource, coalesce(f.rdb$default_source, '') DefaultSource, f.rdb$null_flag NullFlag " +
               "from rdb$fields f " +
              $"where f.rdb$FIELD_NAME not starting with 'RDB$' and f.rdb$FIELD_NAME not starting with 'MON$' and f.rdb$FIELD_NAME not starting with 'SEC$' " +
               "order by f.rdb$field_name; ";
         var reader = command.ExecuteReader();
         while (reader.Read())
         {
             var name = (string)reader["FieldName"];
             var size = (reader["CharSize"] == DBNull.Value) ? null : (short?)reader["CharSize"];
             var subType = (reader["SubType"] == DBNull.Value) ? null : (short?)reader["SubType"];
             var precision = (reader["FieldPrecision"] == DBNull.Value) ? null : (short?)reader["FieldPrecision"];
             var scale = (reader["FieldScale"] == DBNull.Value) ? null : (short?)reader["FieldScale"];
             var fieldLength = (reader["FieldLength"] == DBNull.Value) ? null : (short?)reader["FieldLength"];
             var type = new FieldType((short)reader["Type"], subType, size, precision, scale, fieldLength);
             var validationSource = (string)reader["ValidationSource"];
             var defaultSource = (string)reader["DefaultSource"];
             var nullFlag = reader["NullFlag"] == DBNull.Value;
             yield return new DomainInfo(name, type, validationSource, defaultSource, nullFlag);
         }
     }
 }
开发者ID:degarashi0913,项目名称:FAManagementStudio,代码行数:26,代码来源:DatabaseInfo.cs


示例6: PrepareDb

		public override void PrepareDb()
		{
			// clean
			if(File.Exists(PathToDb))
			{
				File.Delete(PathToDb);
			}
			// create db
			FbConnection.CreateDatabase(pConnectionString);
			// create tables
			string script;
			using(StreamReader reader = new StreamReader(PathToSchema))
			{
				script = reader.ReadToEnd();
			}
			FbScript sqls = new FbScript(script);
			if(sqls.Parse() <= 0)
			{
				throw new DbException("No DB schema found.");
			}
			using(FbConnection connection = new FbConnection(pConnectionString))
			{
				connection.Open();
				foreach(FbCommand create in sqls.Results.Select(sql => new FbCommand(sql, connection)))
				{
					create.ExecuteNonQuery();
				}
			}
		}
开发者ID:antgraf,项目名称:Embedded-DB-.Net-Performance-Test,代码行数:29,代码来源:DbTestFireBird.cs


示例7: BuildCommand

		protected FbCommand BuildCommand(FbConnection connection, string collectionName, string[] restrictions)
		{
			string          filter = String.Format("CollectionName='{0}'", collectionName);
			StringBuilder	builder = this.GetCommandText(restrictions);
			DataRow[]       restriction = connection.GetSchema(DbMetaDataCollectionNames.Restrictions).Select(filter);
			FbTransaction	transaction = connection.InnerConnection.ActiveTransaction;
			FbCommand		command	= new FbCommand(builder.ToString(), connection, transaction);

			if (restrictions != null && restrictions.Length > 0)
			{
				int index = 0;

				for (int i = 0; i < restrictions.Length; i++)
				{
					string rname = restriction[i]["RestrictionName"].ToString();
					if (restrictions[i] != null)
					{
						// Catalog, Schema and TableType are no real restrictions
						if (!rname.EndsWith("Catalog") && !rname.EndsWith("Schema") && rname != "TableType")
						{
							string pname = String.Format(CultureInfo.CurrentUICulture, "@p{0}", index++);

							command.Parameters.Add(pname, FbDbType.VarChar, 255).Value = restrictions[i];
						}
					}
				}
			}					

			return command;
		}
开发者ID:cafee,项目名称:NETProvider,代码行数:30,代码来源:FbSchema.cs


示例8: RetornaTabelaUsuariosCadastrados

        public DataTable RetornaTabelaUsuariosCadastrados()
        {
            FbConnection conex = new FbConnection(conexao);

            string query = "SELECT CDUSUARIO, DSUSUARIO, DSMAE, DTNASCIMENTO FROM TBUSUARIO";
            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,代码行数:25,代码来源:PacienteFirebird.cs


示例9: _executeReader

        protected List<Dictionary<string, string>> _executeReader(FbConnection conn, FbTransaction trans, string query, Dictionary<string, object> prms)
        {
            List<Dictionary<string, string>> ret = new List<Dictionary<string, string>>();

            using (FbCommand cmd = new FbCommand(query, conn, trans))
            {
                foreach (var prm in prms)
                    cmd.Parameters.AddWithValue(prm.Key, prm.Value);

                using (FbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Dictionary<string, string> row = new Dictionary<string, string>();

                        Object[] values = new Object[reader.FieldCount];
                        reader.GetValues(values);

                        for (int jj = 0; jj < reader.FieldCount; jj++)
                            row.Add(reader.GetName(jj).ToLower(), values[jj].ToString());

                        ret.Add(row);
                    }
                }
            }

            return ret;
        }
开发者ID:kindprojects,项目名称:workstation,代码行数:28,代码来源:SCommand.cs


示例10: _executeNonQuery

        protected string _executeNonQuery(FbConnection conn, FbTransaction trans, string query, Dictionary<string, object> prms, bool isReturning)
        {
            string ret = "";

            using (FbCommand cmd = new FbCommand(query, conn, trans))
            {
                foreach (var prm in prms)
                    cmd.Parameters.AddWithValue(prm.Key, prm.Value);

                if (isReturning)
                {
                    FbParameter outparam = new FbParameter("@out", FbDbType.VarChar)
                    {
                        Direction = ParameterDirection.Output
                    };
                    cmd.Parameters.Add(outparam);

                    cmd.ExecuteNonQuery();
                    ret = outparam.Value as string;
                }
                else
                    cmd.ExecuteNonQuery();
            }

            return ret;
        }
开发者ID:kindprojects,项目名称:workstation,代码行数:26,代码来源:SCommand.cs


示例11: belEscrituracao

        public belEscrituracao(belInfNFe pInfNFe, FbConnection pfbConexao)
        {
            bProdutorRural = false;
            objInfNFe = pInfNFe;
            string scdClifor = string.Empty;

            Conexao = pfbConexao;//MontaConexaoEscritor();


            if (objInfNFe.Empresa != null)
            {
                string sTipoLanc = TipoLancamento();
                string sDoc = string.Empty;

                #region Clientes/Fornecedores
                if (objInfNFe.BelDest.Cnpj != null)
                {
                    sDoc = FormataString(objInfNFe.BelDest.Cnpj.ToString(), "CNPJ");
                }
                else
                {
                    sDoc = FormataString(objInfNFe.BelDest.Cpf.ToString(), "CPF");
                }


                if (!RegistroExiste("CLIFOR", (objInfNFe.BelDest.Cnpj != null ? "CD_CGC = '" : "CD_CPF ='") + sDoc + "'", "CD_CLIFOR"))
                {

                    scdClifor = CadastraCliFor(sDoc);
                }
                else
                {
                    scdClifor = BuscaCodigoClifor(sDoc);
                }

                //OS_28165
                String sQuery = string.Format("UPDATE CLIFOR SET CD_MUNIC = '{0}' WHERE CD_CLIFOR = '{1}'", objInfNFe.BelDest.Cmun, scdClifor);
                using (FbCommand cmd = new FbCommand(sQuery, Conexao))
                {
                    if (Conexao.State != ConnectionState.Open)
                    {
                        Conexao.Open();
                    }
                    cmd.ExecuteNonQuery();
                }

                objInfNFe.Cdclifor = scdClifor;
                #endregion

                bool bSaida = true; //  NotaSaida();
                if (sTipoLanc == "E")
                {
                    bSaida = false;
                }
                Escritura(bSaida);



            }
        }
开发者ID:dramosti,项目名称:GeraXml_2.0,代码行数:60,代码来源:belEscrituracao.cs


示例12: BeginTrasactionTest

		public void BeginTrasactionTest()
		{
			string connectionString = this.BuildConnectionString();

			FbConnection conn01 = new FbConnection(connectionString);
			conn01.Open();
			FbTransaction txn01 = conn01.BeginTransaction(IsolationLevel.Unspecified);
			txn01.Rollback();
			conn01.Close();

			FbConnection conn02 = new FbConnection(connectionString);
			conn02.Open();
			FbTransaction txn02 = conn02.BeginTransaction(IsolationLevel.ReadCommitted);
			txn02.Rollback();
			conn02.Close();

			FbConnection conn03 = new FbConnection(connectionString);
			conn03.Open();
			FbTransaction txn03 = conn03.BeginTransaction(IsolationLevel.ReadUncommitted);
			txn03.Rollback();
			conn03.Close();

			FbConnection conn04 = new FbConnection(connectionString);
			conn04.Open();
			FbTransaction txn04 = conn04.BeginTransaction(IsolationLevel.RepeatableRead);
			txn04.Rollback();
			conn04.Close();

			FbConnection conn05 = new FbConnection(connectionString);
			conn05.Open();
			FbTransaction txn05 = conn05.BeginTransaction(IsolationLevel.Serializable);
			txn05.Rollback();
			conn05.Close();
		}
开发者ID:masroore,项目名称:Firebird-NETProvider,代码行数:34,代码来源:FbConnectionTests.cs


示例13: 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


示例14: abrir

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


示例15: Main

        private static void Main(string[] args)
        {
            if (File.Exists("Data/database.fdb"))
            {
                File.Delete("Data/database.fdb");
            }

            FbConnection.CreateDatabase(GetConnectionString());

            using (var conn = new FbConnection(GetConnectionString()))
            {
                conn.Open();
                if (File.Exists("Data/database.sql"))
                {
                    var file = new FileInfo("Data/database.sql");
                    string script = file.OpenText().ReadToEnd();

                    using (FbCommand createTable = conn.CreateCommand())
                    {
                        createTable.CommandText = script;
                        createTable.ExecuteNonQuery();
                    }
                }
            }
        }
开发者ID:nate0001,项目名称:AIR,代码行数:25,代码来源:Program.cs


示例16: PopulainfCarga

        public void PopulainfCarga(belinfCte objbelinfCte, FbConnection conn, string sCte)
        {
            try
            {
                StringBuilder sQuery = new StringBuilder();
                sQuery.Append("Select ");
                sQuery.Append("coalesce(conhecim.ds_prodpred,'')proPred, ");
                sQuery.Append("coalesce(nfconhec.vl_nf,'')vMerc ");
                sQuery.Append("from conhecim ");
                sQuery.Append("join nfconhec on  conhecim.nr_lanc = nfconhec.nr_lancconhecim ");
                sQuery.Append("join empresa on conhecim.cd_empresa = empresa.cd_empresa ");
                sQuery.Append("where   conhecim.nr_lanc ='" + sCte + "' ");
                sQuery.Append("and empresa.cd_empresa ='" + belStatic.CodEmpresaCte + "'");



                FbCommand fbConn = new FbCommand(sQuery.ToString(), conn);
                fbConn.ExecuteNonQuery();
                FbDataReader dr = fbConn.ExecuteReader();

                objbelinfCte.infCTeNorm = new belinfCTeNorm();
                objbelinfCte.infCTeNorm.infCarga = new belinfCarga();
                while (dr.Read())
                {
                    objbelinfCte.infCTeNorm.infCarga.vCarga += Convert.ToDecimal(dr["vMerc"].ToString().Replace(".", ","));
                    objbelinfCte.infCTeNorm.infCarga.proPred =belUtil.TiraSimbolo( dr["proPred"].ToString(),"");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:dramosti,项目名称:GeraXml_2.0,代码行数:33,代码来源:daoinfCarga.cs


示例17: BaseTreeNavigator

        public BaseTreeNavigator()
        {
            InitializeComponent();

            //SetConnections();

            // get the connection string from app.config and create the connections
            string sqlConnectionString = ConfigurationManager.ConnectionStrings["sqlServerConnectionString"].ConnectionString;
            string fbConnectionString = ConfigurationManager.ConnectionStrings["firebirdConnectionString"].ConnectionString;

            //sql server
            sqlConnection = new SqlConnection(sqlConnectionString);
            sqlConnectionDaughter = new SqlConnection(sqlConnectionString);

            sqlCommand = new SqlCommand();
            sqlCommand.Connection = sqlConnection;

            sqlCommandDaughter = new SqlCommand();
            sqlCommandDaughter.Connection = sqlConnectionDaughter;

            //firebird
            fbConnection = new FbConnection(fbConnectionString);
            fbConnectionDaughter = new FbConnection(fbConnectionString);

            fbCommand = new FbCommand();
            fbCommand.Connection = fbConnection;

            fbCommandDaughter = new FbCommand();
            fbCommandDaughter.Connection = fbConnectionDaughter;
        }
开发者ID:KingR1,项目名称:MsSqlFirebirdDb,代码行数:30,代码来源:BaseTreeNavigator.cs


示例18: 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


示例19: DataBaseOpenConnection

 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;
 }
开发者ID:Igorurievich,项目名称:GPS-Tracking-System,代码行数:25,代码来源:TCPSERVER_SERVICE.cs


示例20: SimpleSelectTest

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

            csb.Enlist = true;

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

                    using (FbCommand command = new FbCommand("select * from TEST where (0=1)", c))
                    {
                        using (FbDataReader r = command.ExecuteReader())
                        {
                            while (r.Read())
                            {
                            }
                        }
                    }
                }

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# FirebirdClient.FbDataAdapter类代码示例发布时间:2022-05-24
下一篇:
C# FirebirdClient.FbCommandBuilder类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap