c#有一个文本框为空,保存时如何实现数据库存入的是字符"NULL"
c#有一个文本框为空,保存时如何实现数据库存入的是字符 "NULL "
------解决方案--------------------比较笨的方法 
 string strTEXT1=TEXT1.text.tostring; 
 string strText2=Text2.text.tostring;//判断为空后需要存入‘NULL’的文本框   
 if strText2.TEXT= " "; 
 sql= "insert into test values( ' "+strTEXT1+ " ', 'NULL ') " 
 ELSE 
 sql= "insert into test values( ' "+strTEXT1+ " ', ' "+strTEXT2+ " ') "
------解决方案--------------------string strText; 
 if TEXT1.text =  " " 
 strText =  "NULL " 
 else 
 strText = TEXT1.text   
 sql= "insert into test values( ' "+strText+ " ') "
------解决方案--------------------System.DBNull.Value    
 if (txtID.Text.Trim() = " " ) 
             { 
                 SqlParameter pa = new SqlParameter( "id ").Value = System.DBNull.Value; 
             }
------解决方案--------------------判断手动传System.DBNull.Value