日期:2014-05-16 浏览次数:20872 次
private void Test_Load(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection();
cn.ConnectionString = "data source=.;initial catalog=TestOnLine;integrated security=true;";
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandText = "select top 20 * from Exercise order by newid()";
cn.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
txtExercise.Text = " "+dr.GetString(1) +"\n" +
"\n" + " A." + dr.GetString(2) +
"\n" + " B." + dr.GetString(3) +
"\n" + " C." + dr.GetString(4) +
"\n" + " D." + dr.GetString(5);
dr.Close();
cn.Close();
}