VS2008でフォームを設計しました。次のフィールドを含むデータベーステーブルがあります。
Fname (char)
MailFrom (char)
MailTo (char)
Subject (char)
Body (char)
MailID (int)
次に、データベースからデータを抽出し、フォームのそれぞれのフィールドに表示します。
私の背後にあるコードは次のとおりです。
SqlConnection conn = new SqlConnection(
"Data Source=PTZ1\\SQLEXPRESS;Initial Catalog = test; Integrated Security=SSPI;User ID=sa; Password=sa@; Trusted_Connection=True;");
SqlDataReader rdr = null;
try
{
// Open the connection
conn.Open();
// Pass the connection to a command object
SqlCommand cmd = new SqlCommand("select * from testing", conn);
//
// Use the connection
//
// get query results
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
Console.WriteLine(rdr[]);
}
}
finally
{
// close the reader
if (rdr != null)
{
rdr.Close();
}
// Close the connection
if (conn != null)
{
conn.Close();
}
}
コンソールにデータを保存して表示するにはどうすればよいですか