• 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();
                 }
             }
         }
     }
     
     
     
     
     
     
     
     
     
  • 相关阅读:
    Linux下查看某个命令的参数
    Vue
    SpringBoot vue
    Axios 中文说明
    一个很有趣的示例Spring Boot项目,使用Giraphe CMS和Spring Boot
    微信公众号 文章的爬虫系统
    为RecyclerView添加item的点击事件
    Android NineGridLayout — 仿微信朋友圈和QQ空间的九宫格图片展示自定义控件
    今日头条 --新闻阅读器
    int android.support.v7.widget.RecyclerView$ViewHolder.mItemViewType' on a null.....
  • 原文地址:https://www.cnblogs.com/wang2650/p/5288189.html
Copyright © 2020-2023  润新知