2013. 11. 6. 10:26
static void HasRows(SqlConnection connection)
{
using (connection)
{
SqlCommand command = new SqlCommand(
"SELECT CategoryID, CategoryName FROM Categories;",
connection);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
Console.WriteLine("{0}\t{1}", reader.GetInt32(0),
reader.GetString(1));
}
}
else
{
Console.WriteLine("No rows found.");
}
reader.Close();
}
}
'.NET > .NET' 카테고리의 다른 글
How to include an external html file in asp.net page (0) | 2013.12.24 |
---|---|
[.NET MVC] Controller to Return an Error Message Instead of a View? (0) | 2013.11.09 |
[ASP.NET] 페이지간 데이터 전송 (0) | 2013.09.13 |
[.NET MVC] 레이저 문법 (0) | 2013.09.09 |
[ASP.NET] [Repeater] Bind, Eval, Contatiner, DataItem (0) | 2013.09.04 |