public static int GetUserTotalCount() { string sql = "SELECT count(*) as totalcount FROM users u INNER JOIN user_groups g on u.gid=g.gid "; using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection")) { DataSet ds = new DataSet(); db.Fill(ds, sql); try { return(Convert.ToInt32(ds.Tables[0].Rows[0]["totalcount"])); } catch (Exception ex) { throw ex; } } }