我想在表a中查询id=10的数据;
但是如果a中没有id=10的数据,用ExecuteScalar就会报错:没有引用到示例!!
怎么回事,不是返回值为空吗??
换个command方法?

解决方案 »

  1.   


    用这个
    ==============
    myCom.ExecuteNonQuery(); 
    ==================
      

  2.   

    string sql2 = "select PictureName from SortPicture where SortID=" + tpid;
            string path = DataAccess.SqlHelper.ExecuteScalar(conn.constr(), CommandType.Text, sql2).ToString();
            if (path == "" || path == null)
            {
                ((Image)FormView1.FindControl("imgType")).ImageUrl = "Commodity//Img//default.jpg";
            }
            else
            {
                ((Image)FormView1.FindControl("imgType")).ImageUrl = "Commodity//Img//" + path;
            }
    如果tpid不在表中,就会报未引用到实例的错!
    ExecuteNonQuery的返回值是影响的行数吧?我要的是具体字段