日期:2014-05-16 浏览次数:20553 次
public partial class reg : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=P9UAPI0U8CC5WD6\\SQLEXPRESS;Initial Catalog=Qiming;Integrated Security=True");
String sqlStr = "select code,name from question;";
SqlCommand com = new SqlCommand(sqlStr, con);
com.Connection.Open();
SqlDataReader data = com.ExecuteReader();
ques2.DataSource = data;
ques2.DataTextField = "name";
ques2.DataValueField = "code";
ques2.DataBind();
//con.Close();
/*
con = new SqlConnection("Data Source=P9UAPI0U8CC5WD6\\SQLEXPRESS;Initial Catalog=Qiming;Integrated Security=True");
sqlStr = "select code,name from question;";
com = new SqlCommand(sqlStr, con);
com.Connection.Open();
data = com.ExecuteReader();
*/
ques3.DataSource = data;
ques3.DataTextField = "name";
ques3.DataValueField = "code";
ques3.DataBind();
con.Close();
}