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

C# Odbc.OdbcParameter类代码示例

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

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



OdbcParameter类属于System.Data.Odbc命名空间,在下文中一共展示了OdbcParameter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: inserir

 public int inserir(Voos voo)
 {
     OdbcCommand comando;
     int result = 0;
     String comand = "INSERT INTO voo(codigo, data, origem, destino) VALUES(?, ?, ?, ?)";
     OdbcParameter codigo = new OdbcParameter("?", voo.Codigo);
     OdbcParameter data = new OdbcParameter("?", voo.Data);
     OdbcParameter origem = new OdbcParameter("?", voo.Origem);
     OdbcParameter destino = new OdbcParameter("?", voo.Destino);
     try
     {
         comando = new OdbcCommand(comand, conexao);
         comando.Connection.Open();
         comando.Parameters.Add(codigo);
         comando.Parameters.Add(data);
         comando.Parameters.Add(origem);
         comando.Parameters.Add(destino);
         result = comando.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
     finally
     {
         conexao.Close();
     }
     return result;
 }
开发者ID:abnermsantos,项目名称:CompanhiaAerea,代码行数:29,代码来源:VoosDAO.cs


示例2: inserir

 public int inserir(Aviao aviao)
 {
     OdbcCommand comando;
     int result = 0;
     String comand = "INSERT INTO aviao(numeroSerie, modelo) VALUES(?, ?)";
     OdbcParameter numeroSerie = new OdbcParameter("?", aviao.NumeroSerie);
     OdbcParameter modelo = new OdbcParameter("?", aviao.Modelo);
     try
     {
         comando = new OdbcCommand(comand, conexao);
         comando.Connection.Open();
         comando.Parameters.Add(numeroSerie);
         comando.Parameters.Add(modelo);
         result = comando.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
     finally
     {
         conexao.Close();
     }
     return result;
 }
开发者ID:abnermsantos,项目名称:CompanhiaAerea,代码行数:25,代码来源:AviaoDAO.cs


示例3: Execute

        /// <summary>
        /// ����
        /// </summary>
        /// <param name="sql"></param>
        public static int Execute(string sql, string connstr, OdbcParameter[] parameters)
        {
            int n = -1;
            OdbcConnection conn = null;
            try
            {
                conn = GetConnection(connstr);
                OdbcCommand cmd = new OdbcCommand();//sql, conn);
                cmd.CommandText = sql;
                cmd.Connection = conn;
                for (int i = 0; i < parameters.Length; i++)
                {
                    cmd.Parameters.AddWithValue(parameters[i].ParameterName, parameters[i].Value);
                }
                conn.Open();
                n = cmd.ExecuteNonQuery();

            }
            catch (Exception e)
            {
                //MessageBox.Show( sql, "ϵͳ�����������Ա��ϵ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw new DatabaseException(sql + "\n" + e.Message);
            }
            finally
            {
                try { conn.Close(); }
                catch { }
            }
            conn = null;
            return n;
        }
开发者ID:PeterLiuJF,项目名称:ProgrammerHome,代码行数:35,代码来源:OdbcModel.cs


示例4: add_parameter

 public void add_parameter(long value)
 {
     OdbcParameter param = new OdbcParameter();
     param.DbType = DbType.Int64;
     param.Value = value;
     _parameters.Add(param);
 }
开发者ID:Mrknister,项目名称:MUDEngine,代码行数:7,代码来源:BasicSqlExecuter.cs


示例5: inserir

 public int inserir(Cliente cliente)
 {
     OdbcCommand comando;
     int result = 0;
     String comand = "INSERT INTO cliente(nome, cpf, cidade) VALUES(?, ?, ?)";
     OdbcParameter nome = new OdbcParameter("?", cliente.Nome);
     OdbcParameter cpf = new OdbcParameter("?", cliente.Cpf);
     OdbcParameter cidade = new OdbcParameter("?", cliente.Cidade);
     try
     {
         comando = new OdbcCommand(comand, conexao);
         comando.Connection.Open();
         comando.Parameters.Add(nome);
         comando.Parameters.Add(cpf);
         comando.Parameters.Add(cidade);
         result = comando.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
     finally
     {
         conexao.Close();
     }
     return result;
 }
开发者ID:abnermsantos,项目名称:CompanhiaAerea,代码行数:27,代码来源:ClienteDAO.cs


示例6: inserir

 public int inserir(Aeroportos aeroporto)
 {
     OdbcCommand comando;
     int result = 0;
     String comand = "INSERT INTO aeroporto(nome, cidade, codigo) VALUES(?, ?, ?)";
     OdbcParameter nome = new OdbcParameter("?", aeroporto.Nome);
     OdbcParameter cidade = new OdbcParameter("?", aeroporto.Cidade);
     OdbcParameter codigo = new OdbcParameter("?", aeroporto.Codigo);
     try
     {
         comando = new OdbcCommand(comand, conexao);
         comando.Connection.Open();
         comando.Parameters.Add(nome);
         comando.Parameters.Add(cidade);
         comando.Parameters.Add(codigo);
         result = comando.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
     finally
     {
         conexao.Close();
     }
     return result;
 }
开发者ID:abnermsantos,项目名称:CompanhiaAerea,代码行数:27,代码来源:AeroportoDAO.cs


示例7: GetParametroRetorno

        /// <summary>
        /// Sobrescreve o metodo de Paramatro Retorno,adiciona o parametro de "@RETURN_VALUE".
        /// </summary>
        /// <returns>Retorna uma colecao de parametros com o parametro "@RETURN_VALUE" </returns>
        internal override IDataParameter GetParametroRetorno()
        {
            OdbcParameter p = new OdbcParameter("@RETURN_VALUE",OdbcType.Int);
            p.Direction = ParameterDirection.ReturnValue;

            return p;
        }
开发者ID:Altamontanha,项目名称:altamontanha,代码行数:11,代码来源:ConexaoOdbc.cs


示例8: inserir

 public int inserir(Reservas reserva)
 {
     OdbcCommand comando;
     int result = 0;
     String comand = "INSERT INTO reserva(voo, assento, cpf_cliente) VALUES(?, ?, ?)";
     OdbcParameter voo = new OdbcParameter("?", reserva.Voo);
     OdbcParameter assento = new OdbcParameter("?", reserva.Assento);
     OdbcParameter cpf = new OdbcParameter("?", reserva.Cpf_cliente);
     try
     {
         comando = new OdbcCommand(comand, conexao);
         comando.Connection.Open();
         comando.Parameters.Add(voo);
         comando.Parameters.Add(assento);
         comando.Parameters.Add(cpf);
         result = comando.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
     finally
     {
         conexao.Close();
     }
     return result;
 }
开发者ID:abnermsantos,项目名称:CompanhiaAerea,代码行数:27,代码来源:ReservasDAO.cs


示例9: GetParameter

 /// <summary>
 ///  ��ȡһ���²�������
 /// </summary>
 /// <param name="paraName">������</param>
 /// <param name="dbType">������������</param>
 /// <param name="size">������С</param>
 /// <returns>�ض�������Դ�IJ�������</returns>
 public override IDataParameter GetParameter(string paraName,System.Data.DbType dbType,int size)
 {
     OdbcParameter para=new OdbcParameter();
     para.ParameterName=paraName;
     para.DbType=dbType;
     para.Size=size;
     return para;
 }
开发者ID:eopeter,项目名称:dmelibrary,代码行数:15,代码来源:DMEDb_ODBC.cs


示例10: OdbcParameter

 private OdbcParameter(OdbcParameter source) : this()
 {
     ADP.CheckArgumentNull(source, "source");
     source.CloneHelper(this);
     ICloneable cloneable = this._value as ICloneable;
     if (cloneable != null)
     {
         this._value = cloneable.Clone();
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:OdbcParameter.cs


示例11: CreateParameter

 /// <summary>
 /// 
 /// </summary>
 /// <param name="name"></param>
 /// <param name="dbType"></param>
 /// <returns></returns>
 public override DbParameter CreateParameter(string name, Enum dbType, byte? precision, byte? scale)
 {
     if (dbType is OdbcType)
     {
         var p = new OdbcParameter(name, (OdbcType)dbType);
         if (precision.HasValue == true) p.Precision = precision.Value;
         if (scale.HasValue == true) p.Scale = scale.Value;
         return p;
     }
     throw new ArgumentException("dbType must be OdbcType.");
 }
开发者ID:fengweijp,项目名称:higlabo,代码行数:17,代码来源:OdbcDatabase.cs


示例12: MakeParam

        public DbParameter MakeParam(string ParamName, DbType DbType, Int32 Size)
        {
            OdbcParameter param;

            if (Size > 0)
                param = new OdbcParameter(ParamName, (OdbcType)DbType, Size);
            else
                param = new OdbcParameter(ParamName, (OdbcType)DbType);

            return param;
        }
开发者ID:ChalmerLin,项目名称:dnt_v3.6.711,代码行数:11,代码来源:OdbcProvider.cs


示例13: AddParameter

 protected void AddParameter(string key, string val, int value)
 {
     if (lstDbParameters == null)
     {
         lstDbParameters = new List<DbParameter>();
     }
     OdbcParameter oParam = new OdbcParameter();
     oParam.ParameterName = key;
     oParam.Value = val;
     lstDbParameters.Add(oParam);
 }
开发者ID:MumbaiHackerspace,项目名称:HelpingMunicipality,代码行数:11,代码来源:ParentData.cs


示例14: OdbcParameter

 public override DbParameter CréerDBParameter()
 {
     if (this.options.ConnexionODBC == true)
     {
         OdbcParameter param = new OdbcParameter();
         return param;
     }
     else
     {
         SqlParameter param = new SqlParameter();
         return param;
     }
 }
开发者ID:EricMinso,项目名称:ImportExport,代码行数:13,代码来源:ConnexionSQLServer.cs


示例15: ConvertToNativeParameter

        private static IDbDataParameter ConvertToNativeParameter(DbParameter dbParameter)
        {
            IDbDataParameter clone = new OdbcParameter();
            ((OdbcParameter)clone).IsNullable = dbParameter.IsNullable;
            clone.ParameterName = parameterRenderer.RenderParameterName(dbParameter);

            clone.DbType = dbParameter.DbType;
            clone.Direction = dbParameter.Direction;
            clone.Precision = dbParameter.Precision;
            clone.Scale = dbParameter.Scale;
            clone.Size = dbParameter.Size;
            clone.SourceColumn = dbParameter.SourceColumn;
            clone.SourceVersion = dbParameter.SourceVersion;
            clone.Value = dbParameter.Value;

            return clone;
        }
开发者ID:lordfist,项目名称:FistCore.Lib,代码行数:17,代码来源:OdbcCommandBuilder.cs


示例16: InsertReport

    public bool InsertReport()
    {
        bool result = false;

        using (OdbcConnection connection = new OdbcConnection(connectionString))
        {
            using (OdbcCommand command = new OdbcCommand())
            {

                command.Connection = connection;
                command.CommandText = "{CALL Report_insert(?,?,?,?,?)}";
                command.CommandType = CommandType.StoredProcedure;

                OdbcParameter paramColModel = new OdbcParameter("@ColModel", OdbcType.VarChar, 5000);
                paramColModel.Value = this.ColModel;
                command.Parameters.Add(paramColModel);

                OdbcParameter paramColNames = new OdbcParameter("@ColNames", OdbcType.VarChar, 500);
                paramColNames.Value = this.ColNames;
                command.Parameters.Add(paramColNames);

                OdbcParameter paramCurrentData = new OdbcParameter("@CurrentData", OdbcType.VarChar, 5000);
                paramCurrentData.Value = this.ReportName;
                command.Parameters.Add(paramCurrentData);

                OdbcParameter paramReportName = new OdbcParameter("@ReportName", OdbcType.VarChar, 200);
                paramReportName.Value = this.ReportName;
                command.Parameters.Add(paramReportName);

                OdbcParameter paramTableName = new OdbcParameter("@TableName", OdbcType.VarChar, 50);
                paramTableName.Value = this.TableName;
                command.Parameters.Add(paramTableName);

                connection.Open();
                int n = command.ExecuteNonQuery();
                if (n == 1)
                    result = true;
                else
                    result = false;
            }
        }

        return result;
    }
开发者ID:mominbd,项目名称:testing,代码行数:44,代码来源:Report.cs


示例17: InsertTest

		public void InsertTest ()
		{
			OdbcConnection conn = (OdbcConnection) ConnectionManager.Singleton.Connection;
			ConnectionManager.Singleton.OpenConnection ();

			try {
				OdbcCommand OdbcCmd = conn.CreateCommand ();
				OdbcCmd.CommandType = CommandType.Text;
				OdbcCmd.CommandText = "SELECT fname FROM employee WHERE lname=? AND age=?";

				/*OdbcParameter p1Lname = */OdbcCmd.Parameters.Add ("@lname", OdbcType.Text, 15);
				OdbcParameter p2Age = new OdbcParameter (); //not initialized and not yet added
				OdbcParameter p3Tmp = new OdbcParameter ("p3", "abc"); //not added

				Assert.AreEqual (1, OdbcCmd.Parameters.Count, "#1 Initialization error, the collection does not contain desired no. of parameters");
				OdbcCmd.Parameters.Insert (1, p2Age); //Inserting the second parameter
				Assert.AreEqual (2, OdbcCmd.Parameters.Count, "#2 The collection should contain 2 parameters");
				
				//inserting at upper boundary
				OdbcCmd.Parameters.Insert (OdbcCmd.Parameters.Count, p3Tmp); //Inserting the third parameter, with name and value at index = count
				Assert.AreEqual (3, OdbcCmd.Parameters.Count, "#3 The collection should contain 2 parameters");

				//check the inserted positions
				Assert.AreEqual (0, OdbcCmd.Parameters.IndexOf ("@lname"), "#4 The first parameter must be at index 0");
				Assert.AreEqual (1, OdbcCmd.Parameters.IndexOf (p2Age), "#5 The inserted parameter p2Age must be at index 1");
				Assert.AreEqual (2, OdbcCmd.Parameters.IndexOf (p3Tmp), "#6 The inserted parameter p3Tmp must be at index 2");
				Assert.AreEqual (2, OdbcCmd.Parameters.IndexOf ("p3"), "#7 The inserted parameter p3 must be at index 2");
				Assert.AreEqual (-1, OdbcCmd.Parameters.IndexOf ("non-existing-parameter"), "#8 Non-existing parameters should return -1");
				
				//check for default names and default values
				Assert.AreEqual ("Parameter1", OdbcCmd.Parameters[1].ParameterName, "#9 Parameters inserted without any name must get a default name");
				Assert.AreEqual (null, OdbcCmd.Parameters[1].Value, "#10 Parameters inserted without any value must have null value");
				
				Assert.AreEqual ("p3", OdbcCmd.Parameters[2].ParameterName, "#11 Parameters inserted without any name must get a default name");
				Assert.AreEqual ("abc", OdbcCmd.Parameters[2].Value, "#12 Parameters inserted without any value must have null value");
				
				Assert.AreEqual (OdbcType.NVarChar,OdbcCmd.Parameters[1].OdbcType, "#13 Parameters with null value must be of type NVarChar");
				Assert.AreEqual (OdbcType.Text,OdbcCmd.Parameters[0].OdbcType, "#14 Parameter at index 0 is of type Text");
			} finally {
				ConnectionManager.Singleton.CloseConnection ();
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:42,代码来源:OdbcParameterCollectionTest.cs


示例18: OdbcTypeTest

                public void OdbcTypeTest ()
                {
			OdbcParameter param = new OdbcParameter ();
			Assert.AreEqual (OdbcType.NVarChar, param.OdbcType, "#1");

			// change test
			param.OdbcType = OdbcType.Int;
			Assert.AreEqual (OdbcType.Int, param.OdbcType, "#2");

			param = new OdbcParameter ("test", 10);
			Assert.AreEqual (OdbcType.Int, param.OdbcType, "#3");
			param.OdbcType = OdbcType.Real;
			Assert.AreEqual (OdbcType.Real, param.OdbcType, "#4");
			Assert.AreEqual (10, param.Value, "#5");

			param = new OdbcParameter ("test", OdbcType.NText);
			Assert.AreEqual (null, param.Value, "#6");
			Assert.AreEqual (OdbcType.NText, param.OdbcType, "#7");

			param = new OdbcParameter ("test", OdbcType.Binary);
			Assert.AreEqual (null, param.Value, "#8");
			Assert.AreEqual (OdbcType.Binary, param.OdbcType, "#9");
                }
开发者ID:nlhepler,项目名称:mono,代码行数:23,代码来源:OdbcParameterTest.cs


示例19: Test_Various_DataTypes2

        public static void Test_Various_DataTypes2()
        {

            TestCases.ExecuteSQL("drop table if exists t", conn);

            string sql = "create table t(";
            sql += "c_integer_ai integer AUTO_INCREMENT, "; //1
            sql += "c_smallint smallint, "; //2
            sql += "c_integer integer, "; //3
            sql += "c_bigint bigint, "; //4
            sql += "c_numeric numeric(15,1), "; //5
            sql += "c_float float, ";//6
            sql += "c_decimal decimal(15,3), ";//7
            sql += "c_double double, ";//8
            sql += "c_char char, ";//9
            sql += "c_varchar varchar(4096), ";//10
            sql += "c_time time, ";//11
            sql += "c_date date, ";//12
            sql += "c_timestamp timestamp, ";//13
            sql += "c_datetime datetime, ";//14
            sql += "c_bit bit(1), ";//15
            sql += "c_varbit bit varying(4096), ";//16
            sql += "c_monetary monetary, ";//17
            sql += "c_string string";//18
            sql += ")";
            TestCases.ExecuteSQL(sql, conn);

            using (OdbcCommand cmd = new OdbcCommand(null, conn))
            {
                sql = "insert into t values(?, ?, ?, ?, ?, ?,";
                sql += "?, ?, ?, ?, ?, ?,";
                sql += "?, ?, ?, ?, ?, ?";
                sql += ")";

                OdbcParameter p1 = new OdbcParameter("?p1", OdbcType.Int);
                p1.Value = 1;
                cmd.Parameters.Add(p1);

                OdbcParameter p2 = new OdbcParameter("?p2", OdbcType.SmallInt);
                p2.Value = 11;
                cmd.Parameters.Add(p2);

                OdbcParameter p3 = new OdbcParameter("?p3", OdbcType.Int);
                p3.Value = 111;
                cmd.Parameters.Add(p3);

                OdbcParameter p4 = new OdbcParameter("?p4", OdbcType.BigInt);
                p4.Value = 1111;
                cmd.Parameters.Add(p4);

                OdbcParameter p5 = new OdbcParameter("?p5", OdbcType.Numeric);
                p5.Value = 1.1;
                cmd.Parameters.Add(p5);

                OdbcParameter p6 = new OdbcParameter("?p6", OdbcType.Double);
                p6.Value = 1.11;
                cmd.Parameters.Add(p6);

                OdbcParameter p7 = new OdbcParameter("?p7", OdbcType.Decimal);
                p7.Value = 1.111;
                cmd.Parameters.Add(p7);

                OdbcParameter p8 = new OdbcParameter("?p8", OdbcType.Double);
                p8.Value = 1.1111;
                cmd.Parameters.Add(p8);

                OdbcParameter p9 = new OdbcParameter("?p9", OdbcType.Char);
                p9.Value = 'a';
                cmd.Parameters.Add(p9);

                OdbcParameter p10 = new OdbcParameter("?p10", OdbcType.VarChar);
                p10.Value = "abcdfghijk";
                cmd.Parameters.Add(p10);

                cmd.CommandText = sql;

                cmd.ExecuteNonQuery();
            }

            sql = "select * from t";
            using (OdbcCommand cmd = new OdbcCommand(sql, conn))
            {
                OdbcDataReader reader = cmd.ExecuteReader();
                while (reader.Read()) //only one row will be available
                {
                    Assert.IsTrue(reader.GetInt32(0) == 1);
                    Assert.IsTrue(reader.GetInt16(1) == 11);
                    Assert.IsTrue(reader.GetInt32(2) == 111);
                    Assert.IsTrue(reader.GetInt64(3) == 1111);
                    Assert.IsTrue(reader.GetDecimal(4) == (decimal)1.1);
                    Assert.IsTrue(reader.GetFloat(5) == (float)1.11); //"Single"
                    Assert.IsTrue(reader.GetDecimal(6) == (decimal)1.111);
                    Assert.IsTrue(reader.GetDouble(7) == (double)1.1111);
                    Assert.IsTrue(reader.GetString(8) == "a"); //"String" ("Char" in CUBRID)

                    Assert.IsTrue(reader.GetString(9) == "abcdfghijk"); //"String" ("String in CUBRID)
                }
            }

            TestCases.ExecuteSQL("drop table if exists t", conn);
//.........这里部分代码省略.........
开发者ID:CUBRID,项目名称:cubrid-odbc,代码行数:101,代码来源:TestDataTypes.cs


示例20: GetOdbcCommand

 public override OdbcCommand GetOdbcCommand(string cmdsql, OdbcParameter[] paras)
 {
     OdbcCommand cmd = new OdbcCommand(cmdsql, mysqlconn);
     if (paras != null)
         for (int i = 0; i < paras.Length; i++)
         {
             cmd.Parameters.Add(paras[i]);
         }
     return cmd;
 }
开发者ID:eddylin2015,项目名称:ES_TABLE,代码行数:10,代码来源:ES_DataLayer.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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