select * from table1 where mytest="" select * from table1 where mytest=null这两句有点问题,如果数据库中的数据为null(而不是""),则select * from table1 where mytest=""是取不到任何数据的; select * from table1 where mytest=null也有语法错误,应该是mytest is null这样应该没有什么问题了。关于session的判断问题,如果Session["Admin"]==""或者==null都有问题的话,不妨这样判断:if len(session("admin"))=0) then ..... end if试一下就知道了
表示字符串为空才用""
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误:
行 30: private void Page_Load(object sender, System.EventArgs e)
行 31: {
行 32: if(Session["admin"] == null)
行 33: {
行 34: Response.Write("错误的访问");
session是对象,可以用null来判断
我一直这样做
楼上的注意大小写是什么大小写?Session["admin"]??
那么用SQL语句如何把该字段为空的所有记录都选择出来呢?
select * from table1 where mytest=""
select * from table1 where mytest=null
我都试过了,都不行,到底怎么判断呢?
select * from table1 where mytest=null这两句有点问题,如果数据库中的数据为null(而不是""),则select * from table1 where mytest=""是取不到任何数据的;
select * from table1 where mytest=null也有语法错误,应该是mytest is null这样应该没有什么问题了。关于session的判断问题,如果Session["Admin"]==""或者==null都有问题的话,不妨这样判断:if len(session("admin"))=0) then
.....
end if试一下就知道了