Wednesday, April 15, 2015

count total number if rows in table

    protected void Button2_Click(object sender, EventArgs e)
    {
        cmd = new SqlCommand("select count(id) from std", con);
        con.Open();
        int c = Convert.ToInt32(cmd.ExecuteScalar());//ExecuteScalar is use when you want single value result like number of rows, total of salary average etc.
        Response.Write("total no of records are : " + c);

    }

No comments:

Post a Comment