例如:數據庫中的STATE字段對應的數字是1與0,當要將1顯示在gridview上,顯示為‘是’,0顯示為‘否’,可以通過下面的語句實現。BZZT是STATE的別名,gridview綁定的時候(fieldname),要綁定到BZZT上。
EG1:
select '0' as CHECKED,ID,NAME,STATE,case IMPORT_STATE when '0' then '否' else '是' end as BZZT from OU_INTERFACE where 1=1;
EG2:
select '0' as CHECKED,表名.* ,case IMPORT_STATE when '0' then '否' else '是' end as BZZT from 表名 where import_state='" +需要傳遞進來的變量+ "'"
EG3:
如果在代碼中缺少END,會出現如下錯誤:  string strSqlSended = "select '0'as CHECKED,CASE LX WHEN '01' THEN '轉收'"
+ "WHEN '02' THEN '轉付'"
+ "WHEN '03' THEN '現收'"
+ "WHEN '04' THEN '現付'"
+ "WHEN '05' THEN '內轉'"
+ "WHEN '06' THEN '應收'"
+ "WHEN '07' THEN '應付' END AS BZZT,"
+ "from 表名 "