I have to use query instead of stored procedure in order to dynamically select top %n record from table, b/c stored procedure can't take a parameter and used it like "select top @number ...". Finally, this is what I implemented:
SqlCommand cmdSql = new SqlCommand();
cmdSql.Connection = cnnSql;
cmdSql.CommandType = CommandType.Text;
string Query = String.Format(@"SELECT TOP {0}
[HelpID],
[CategoryID],
[Question],
[Answer],
[Hits]
FROM dbo.HelpContent ORDER BY [Hits] DESC",Number.ToString());
cmdSql.CommandText = Query;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment