zoukankan      html  css  js  c++  java
  • 当需要向数据库插入空值时,sql语句的判断

     方法如下:

     1.int代表整形。

     2.string 代表 字符型。

      3.datetime ,日期类型判断如下

      if(account.date!=Datetime.MinValue)

       {

      Str1.Append("date=' "+account.date+" ', ")

    }

     1  public int Update(AccountInfo account)
     2 {
     3     StringBuilder str1=new StringBuilder();
           StringBuilder str2=new StringBuilder();
    
     4    // int
     5    if( account.number!=0)
     6       {
     7          str1.Append("Number="+account.number",")
     8       }else
     9         {
    10             str1.Append(" Number=null , ");
    11         }
    12 
    13     //string
    14     if(account.Name!=null&&account.Name!="")
    15      {
    16          str1.Append("Name=' " + account.Name+ " ' ,");
    17       }else
    18      {
    19          str1.Append(" Name=' ' , ");
    20      }
    
              str2.Append(" update table  set ");
              str2.Append(str1.ToString().Remove(str1.Length-1));
              str2.Append(" where ID="+ Account.ID+"");
              return SqlHelper.ExecuteSql(str2.ToString);
    21 
    22 
    23 
    24 }
    View Code
  • 相关阅读:
    Emacs教程
    华为上机测试 2015
    奇偶排序
    C语言中的EOF和回车不一样
    jquery 使用方法
    1116
    1115
    1109
    Oracle14~23
    get与post的区别
  • 原文地址:https://www.cnblogs.com/lxyang/p/5048296.html
Copyright © 2011-2022 走看看