select (select sum(money) from weblog where convert(varchar(7),buy_time,120)=convert(varchar(7),getdate(),120)) as theM,
(select sum(money) from weblog where convert(varchar(10),buy_time,120)=convert(varchar(10),getdate(),120) ) as theday,
(select sum(money) from weblog where convert(varchar(10),buy_time,120)=convert(varchar(10),dateadd(month,-1,getdate()),120) ) as lastM上面的数据库分别取出theM,theday,lastM并在VS.NET中从 myread = mycmd.ExecuteReader
If myread.Read Then
theM.Text = myread("theM")
today.Text = myread("theday")
onM.Text = myread("lastM")当其中取的任何一个值为空时,页面就会报错,无法将NULL转换成string,请问各位,应该怎么办呢?
(select sum(money) from weblog where convert(varchar(10),buy_time,120)=convert(varchar(10),getdate(),120) ) as theday,
(select sum(money) from weblog where convert(varchar(10),buy_time,120)=convert(varchar(10),dateadd(month,-1,getdate()),120) ) as lastM上面的数据库分别取出theM,theday,lastM并在VS.NET中从 myread = mycmd.ExecuteReader
If myread.Read Then
theM.Text = myread("theM")
today.Text = myread("theday")
onM.Text = myread("lastM")当其中取的任何一个值为空时,页面就会报错,无法将NULL转换成string,请问各位,应该怎么办呢?
{
//为null
}
else
}
//不为null
}
if myread("theday")==null then
//为null
else
//不为null
endif
可以寫個function
當數據不為空時傳會原數據
為空就傳會想要的數據
或者在sql語句里 用 isnull
上面的代码意思是:
如果myread("theday")的值不是为空那么值就是myread("theday"),为空则用值为""