SqlDataReader
using (mycon)
{ //using语句与try catch finally结合使用
mycon.Open();
// MessageBox.Show("dakai");
string sql = "select * from [hf_zw].[dbo].[t_reservation] where reservation_id=566";
SqlCommand mycom = new SqlCommand(sql, mycon);
//声明datareader
SqlDataReader mydr;
mydr = mycom.ExecuteReader();
// DateTime dtcreate;
while (mydr.Read())
{
//if (DateTime.TryParse(mydr["reservation_service_time"].ToString(), out dtcreate))
//{
// textBox1.Text = dtcreate.ToShortDateString();
//}
textBox1.Text = ((DateTime)mydr["reservation_service_time"]).ToShortDateString();
}
}
}
else
{
MessageBox.Show("请勿快速操作!");
return;
}
}
catch
{
}
finally
{
mycon .Close();
// Console.WriteLine("成功关闭");
}