zoukankan      html  css  js  c++  java
  • CUBRID学习笔记 40 使用net修改数据

    修改

    connection.Open();

      
     string queryString = "UPDATE nation set capital = 'X' where `code` = 'A'";
      
     CUBRIDCommand command = new CUBRIDCommand(queryString, connection);
     Int32 recordsAffected = command.ExecuteNonQuery();
    删除
    // Assumes connection is a valid SqlConnection.
    connection.Open();
     
    string queryString = "DELETE FROM nation where `code` = 'A'";
     
    CUBRIDCommand command = new CUBRIDCommand(queryString, connection);
    Int32 recordsAffected = command.ExecuteNonQuery();
     
     
    写入blob类型数据
    using CUBRID.Data.CUBRIDClient;
         
      namespace BLOBExample
      {
          class Program
          {
              static void Main(string[] args)
              {
                  CUBRIDConnectionStringBuilder sb = new CUBRIDConnectionStringBuilder("localhost""demodb""public""""33000"true);
                  using (CUBRIDConnection conn = new CUBRIDConnection(sb.GetConnectionString()))
                  {
                      conn.Open();
         
                      string sql = "insert into Employees (Photo) values(?)";
                      using (CUBRIDCommand cmd = new CUBRIDCommand(sql, conn))
                      {
                          CUBRIDBlob Blob = new CUBRIDBlob(conn);
                          byte[] bytes;
                          BinaryReader _reader = new BinaryReader(File.Open(@".John.jpg", FileMode.Open));
                          int length = (int)_reader.BaseStream.Length;
                          bytes = _reader.ReadBytes(length);
       
                          Blob.setBytes(1, bytes);
                          CUBRIDParameter param = new CUBRIDParameter();
                          param.ParameterName = "?";
                          param.CUBRIDDataType = CUBRIDDataType.CCI_U_TYPE_BLOB;
                          param.DbType = DbType.Binary;
                          param.Value = Blob;
     
                          cmd.Parameters.Add(param);
                          cmd.ExecuteNonQuery();
                      }
       
                      conn.Close();
                  }
              }
          }
      }
     
     
    写入clob数据
    using CUBRID.Data.CUBRIDClient;
         
     namespace BLOBExample
     {
         class Program
         {
             static void Main(string[] args)
             {
                 CUBRIDConnectionStringBuilder sb = new CUBRIDConnectionStringBuilder("localhost", "demodb", "public", "", "33000", true);
                 using (CUBRIDConnection conn = new CUBRIDConnection(sb.GetConnectionString()))
                 {
                     conn.Open();
         
                     string sql = "insert into Employees(resume) values(?)";
                     using (CUBRIDCommand cmd = new CUBRIDCommand(sql, conn))
                     {
                         StreamReader _reader = new StreamReader(File.Open(@".John.txt", FileMode.Open));
                         string _resume = _reader.ReadToEnd();
                         _reader.Close();
     
                         CUBRIDBlob Blob = new CUBRIDBlob(conn);
                         Clob.setString(1, _resume);
     
                         CUBRIDParameter param = new CUBRIDParameter();
                         param.ParameterName = "?";
                         param.CUBRIDDataType = CUBRIDDataType.CCI_U_TYPE_CLOB;
                         param.Value = Blob;
                         cmd.Parameters.Add(param);
                         cmd.ExecuteNonQuery();
                         cmd.Close();
                     }
       
                     conn.Close();
                 }
             }
         }
     }
     
     
     
     
     
     
     
     
     
  • 相关阅读:
    五、oracle基本建表语句
    二十九、oracle 触发器
    二十七、oracle 异常
    二十八、oracle 视图
    maven项目搭建
    springmvc java对象无法返回json格式问题
    springmvc+mybatis+oracle+druid搭建项目
    Trilateration三边测量定位算法
    滴滴开源:DoraemonKit来了,程序员的开发工具箱
    VUE中index.html什么时候加载的mainjs呢?
  • 原文地址:https://www.cnblogs.com/wang2650/p/5288189.html
Copyright © 2011-2022 走看看