假设以下代码返回整个结果行:
using (SqlCommand cmdMessages = new SqlCommand("SELECT * FROM Email where Sender = @usernameLog", conn))
{
cmdMessages.Parameters.Add(new SqlParameter("@usernameLog", Sender));
using (SqlDataReader reader = cmdMessages.ExecuteReader())
{
while (reader.Read())
{
Console.Write(); // Receiver's Name which comes from database
Console.Write();// The message which comes from same row as the receiver's name
}
}
}
该查询在SQL Server中工作正常。
SQL Server的输出:
User hi
我想在控制台中有相同的输出。
相关分类