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();
                 }
             }
         }
     }
     
     
     
     
     
     
     
     
     
  • 相关阅读:
    常用模块——hashlib模块
    day21作业
    常用模块——configparser模块
    常用模块——xml模块
    常用模块——json模块
    常用模块——shelve模块
    常用模块——pickle模块
    shutil模块
    常用模块——os模块
    简易nagios安装出现的问题及解决方法
  • 原文地址:https://www.cnblogs.com/wang2650/p/5288189.html
Copyright © 2011-2022 走看看