首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

SQL中的空值有关问题 帮帮忙 多谢

2012-02-12 
SQL中的空值问题 帮帮忙 谢谢比如表AID学生1A2NULL现在要这样selectID,学生fromA但要这样显示ID学生1A2就

SQL中的空值问题 帮帮忙 谢谢
比如表   A
      ID   学生
        1     A
        2     NULL
现在要这样   select   ID,学生   from   A  
但要这样显示   ID   学生
                          1       A
                          2        
就这样   比如学生为空的话   就什么都不显示   不是显示出NULL来

[解决办法]
Selecte id , student From A where student <> null
[解决办法]
select ID,nullif(学生, ' ') from A
[解决办法]
不行就用这个:
for(int i = 0;i <dgrdxxx.Items.Count;i++)
{
if(this.dgrdxxx.Items[i].Cells[0].Text == "NULL ")
{
this.dgrdxxx.Items[i].Cells[0].Text = " ";
}

}
[解决办法]
select ID,学生 from A where 学生 is not null
[解决办法]
是用IsNull函数吧:
select id, IsNull(学生, ' ') --当是NULL的时候用空字符表示
form A


[解决办法]
select id, IsNull(学生, ' ') --当是NULL的时候用空字符表示
form A


[解决办法]
where(olereader.reader()){
dr=dt.newRow();
string s=olereader.getstring(0).tostring().trim();
if(s== " ")
dr[0]=s;
dt.rows.add(dr);
}
ds.tables.add(dt);
this.dg.datasource=ds.tables[ "biao "].DefaultView;
dg.databind;
[解决办法]
原来是一个贴子啊,呵呵,
如果score是小数类型且显示为字符串,那么如下:

select cast(isnull(score,0.0) as varchar(10)) as score from A
[解决办法]
select id, 学生=IsNull(学生, ' ') form A
[解决办法]
select isnull(score,0.0) as score from A ,这个试试

热点排行