zoukankan      html  css  js  c++  java
  • CUBRID学习笔记 34 net参数化查询 cubrid教程示例

    using CUBRID.Data.CUBRIDClient;
    
    namespace ParameterExample
    {
        class Program
        {
            static void Main(string[] args)
            {
                CUBRIDConnectionStringBuilder sb = new CUBRIDConnectionStringBuilder("localhost", "demodb", "public", "", "33000");
                using (CUBRIDConnection conn = new CUBRIDConnection(sb.GetConnectionString()))
                {
                    conn.Open();
                    using (CUBRIDCommand cmd = new CUBRIDCommand("create table t(a int, b varchar(20))", conn))
                    {
                        cmd.ExecuteNonQuery();
                    }
    
                    using (CUBRIDCommand cmd = new CUBRIDCommand("insert into t values(?, ?)", conn))
                    {
                        CUBRIDParameter p1 = new CUBRIDParameter("?p1", CUBRIDDataType.CCI_U_TYPE_INT);
                        p1.Value = 1;
                        cmd.Parameters.Add(p1);
    
                        CUBRIDParameter p2 = new CUBRIDParameter("?p2", CUBRIDDataType.CCI_U_TYPE_STRING);
                        p2.Value = "abc";
                        cmd.Parameters.Add(p2);
    
                        cmd.ExecuteNonQuery();
                    }
                    conn.Close();
                }
            }
        }
    }
    

      

    和net差不多,区别是 CUBRID.Data.CUBRIDClient封装了





    using System;
    
    namespace System.Data
    {
        // Summary:
        //     Specifies the type of a parameter within a query relative to the System.Data.DataSet.
        public enum ParameterDirection
        {
            // Summary:
            //     The parameter is an input parameter.
            Input = 1,
            //
            // Summary:
            //     The parameter is an output parameter.
            Output = 2,
            //
            // Summary:
            //     The parameter is capable of both input and output.
            InputOutput = 3,
            //
            // Summary:
            //     The parameter represents a return value from an operation such as a stored
            //     procedure, built-in function, or user-defined function.
            ReturnValue = 6,
        }
    }





  • 相关阅读:
    LeetCode 127. Word Ladder 单词接龙(C++/Java)
    LeetCode 681. Next Closest Time 最近时刻 / LintCode 862. 下一个最近的时间 (C++/Java)
    LeetCode 682. Baseball Game 棒球比赛(C++/Java)
    LeetCode 218. The Skyline Problem 天际线问题(C++/Java)
    小数据池,编码
    字典
    列表
    常见的数据类型
    while循环
    初始python
  • 原文地址:https://www.cnblogs.com/wang2650/p/5287956.html
Copyright © 2011-2022 走看看