日期:2014-05-16 浏览次数:20468 次
dbconn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\我的文档\Visual Studio 2005\Visualizers\WebSites\WebSite3\成绩单.mdb"); dbconn.Open();
da = new OleDbDataAdapter(@" SELECT kecheng.Name_kecheng
FROM ((xuanke INNER JOIN
kecheng ON xuanke.KechengNum_xuanke = kecheng.Num_kecheng) INNER JOIN
banji ON xuanke.BanjiNum_xuanke = banji.Num_banji)
WHERE (banji.Num_banji = 2)", dbconn);
这个查出来的全部值添加到DropDownList1列表下
DataTable dt = new DataTable();
da.Fill(dt);
DropDownList1.DataSource=dt;
dbconn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\我的文档\Visual Studio 2005\Visualizers\WebSites\WebSite3\成绩单.mdb"); dbconn.Open();
da = new OleDbDataAdapter(@" SELECT kecheng.Name_kecheng
FROM ((xuanke INNER JOIN
kecheng ON xuanke.KechengNum_xuanke = kecheng.Num_kecheng) INNER JOIN
banji ON xuanke.BanjiNum_xuanke = banji.Num_banji)
WHERE (banji.Num_banji = 2)", dbconn);
da .SelectCommand.CommandType = CommandType.Text;
DataSet Ds = new DataSet();
da .Fill(Ds, "tb");
DropDownList1.DataSource = Ds.Tables["tb"].DefaultView;
DropDownList1.DataTextField = "Name_kecheng";
DropDownList1.DataValueField = "code";
DropDownList1.DataBind();
sqlconn.Close();