public static DataSet selectDB(string name, out string msg)
    {
        using (SqlConnection cn = new SqlConnection(cnstr))
        {
            if (name != "")
            {
                SqlDataAdapter da = new SqlDataAdapter("select * from sssss where sss='" + name + "'", cn);
                DataSet ds = new DataSet();
                da.Fill(ds);
                msg = "";
                return ds;
            }
            else
            {
                msg = "请输入条件";
                return null;
            }
        }
    }请问这段代码如果name="";时
return的是NULL还是return dataset=null;最近问题问的多了,分有点少了

解决方案 »

  1.   

            public static DataSet selectDB(string name, out string msg)
            {
                DataSet ds = null;
                using (SqlConnection cn = new SqlConnection(cnstr))
                {
                    if (name != "")
                    {
                        SqlDataAdapter da = new SqlDataAdapter("select * from sssss where sss='" + name + "'", cn);
                        ds = new DataSet();
                        da.Fill(ds);
                        msg = "";
                    }
                    else
                    {
                        msg = "请输入条件";
                    }
                }
                return ds;
            }
      

  2.   

    对象是引用类型,空的时候为null
      

  3.   

    请问null是不是可以匹配所有返回类型