try
{
SqlCommand cmd = new SqlCommand
{
Connection = con,
CommandText = "GetJournalByTag",
CommandType = System.Data.CommandType.StoredProcedure
};
cmd.Parameters.AddWithValue("@Tag", Tag);
con.Open();
cmd.ExecuteReader();
con.Close();
return 1;
}
catch
{
return 0;
}
I have code written like this.
I plan to select posts with the same tag, sort them by date, and import them.
Here's what I'm curious about:
- If there are 100 posts, I would like to divide them into 10 pages, 10 each. In this case, what would be the best way to implement it? Any examples or links would be appreciated.
- If I return a value without
con.close
, does theSqlConnection
close? What are the downsides if it doesn't close? - I want to load multiple articles, but I plan to import the
articleModel
class from a SQL Server stored procedure. When executing the procedure, theSelect * from article
code is executed, in this case returns multiple rows. How can I read these multiple rows? - Is there any difference in speed if I use a SQL query like
select * from article
? Is it better to specify all columns? Or is*
better? - Please let me know if you have any coding tips or tips to improve performance when configuring SQL Server or ASP.NET websites!
Thanks for reading.