比如说:
    
        数据库表字段 
        id  int 
        name nvarchar 
        age  int      如果要查询 name=‘张三’ 的人的个数。
          
               怎么写查询语句。
                
           ASP.Net 如何实现?
             

解决方案 »

  1.   

    select count(*) from table where [name]='张三'
      

  2.   

     
          查询语句我也谢出来了。 
           
               .Net中代码如何实现。
                  
                 DBHelper.ExecuteScalar<int>(sql,带参数吗?带什么参数?)
      

  3.   


    select count(1) from table where name='张三'
    把这句话写在一个关于数据库的方法里面即可
      

  4.   

    不知道你的是不是sqlhelper?名字可能不对,不过参数如果是param一般可以排比写下去的,java那些和VB一样写法的见鬼去吧string sql="select count(*) from table where [name]='{0}' and id='{1}'"
    DBHelper.ExecuteNoquery(sql,"张三","1");
      

  5.   

     string sql = "select count(*) from Stat where name=@name";
     return DBHelper.ExecuteScalar<int>(sql,new SqlParamet("@name",SqlDbType.NVarChar,name));
      

  6.   

    string sql = "select count(*) from Stat where name=@name";
     return DBHelper.ExecuteScalar<int>(sql,new SqlParamet("@name",SqlDbType.NVarChar,name)); 
     
      

  7.   

    select count(*) from 表名 where name='张三'
      

  8.   

    我倒。
     public static int ExecuteScalar(string cmdtext, SqlParameter[] para, CommandType ct)
            {
                int value;
                try
                {
                    cmd = new SqlCommand(cmdtext, GetConn());
                    cmd.CommandType = ct;
                    cmd.Parameters.AddRange(para);
                    value = Convert.ToInt32(cmd.ExecuteScalar());
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (cn.State == ConnectionState.Open)
                    {
                        cn.Close();
                    }
                }
                return value;
            }