
运行一下就能在gridview里显示数据了。
语句的话
DataSet
ds
=
new
DataSet()
SqlConnection
con
=
new
SqlConnection(数据库连接字符串)
string
sql="SQl查询语句"
SqlDataAdapter
da
=
new
SqlDataAdapter(sql,
con)
try
{
da.Fill(ds,
"tb")
}
catch
(Exception
ex)
{
throw
new
Exception(ex.ToString())
}
finally
{
con.Close()
}
gridview1.DateSource=
ds.Tables["tb"]
GridView中的数据要写入到数据库,用代码方式实现: 1,ADO.net连接数据 2,Insert数据到数据库 3,Select数据绑定到GridView,搞定。 具体代码要自己写了欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)