SqlCommand cmd = new SqlCommand("SELECT * FROM [order] WHERE date>=@begin AND date<=@end", con);
cmd.Parameters.AddWithValue("@begin",dt1);
cmd.Parameters.AddWithValue("@end", dt2);
这是我的选择声明。我想将结果放入数据网格视图中。如何在asp.net C#中使用数据集存储在gridview中?
Use a 数据库适配器 http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.aspx.
SqlCommand cmd = new SqlCommand("SELECT * FROM [order] WHERE date>=@begin AND date<=@end", con);
cmd.Parameters.AddWithValue("@begin",dt1);
cmd.Parameters.AddWithValue("@end", dt2);
SqlDataAdapter sda = new SqlDataAdapater(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
yourGridView.DataSource = dt;
yourGridView.DataBind();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)