日期:2014-05-17 浏览次数:20530 次
SqlConnection con = new SqlConnection(global::System.Configuration.ConfigurationManager.ConnectionStrings["ZX_WYZJConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
con.Open();
String sql = "select a.CatalogCode,a.UserCode,a.Code,a.Title,a.Text,a.PostDatetime,b.UserName,c.Name from tb_Question a left join tb_UserInfo b on b.Code=a.UserCode left join tb_Catalog c on c.Code=a.CatalogCode order by a.PostDatetime";
SqlDataAdapter sda = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
sda.Fill(ds, "tb_Question");
GridView1.DataSource = ds;
GridView1.DataKeyNames = new string[] { "Code" };
GridView1.DataBind();
con.Close();