•19:44
public void BindView(GridView dg, string datestr, string ars)
{
//打开数据库联接
try
{
myCommand = new OleDbDataAdapter(datestr, objConn);//myCommand 在基类中已经定义了
myCommand.Fill(ds, ars);
dg.DataSource = ds.Tables[ars].DefaultView;
dg.DataBind();
}
catch
{
//报告错误
HttpContext.Current.Response.Write("<script>alert('绑定GridView无法通过!')script>");
}
//关闭数据库连接
objConn.Close();
}
{
//打开数据库联接
try
{
myCommand = new OleDbDataAdapter(datestr, objConn);//myCommand 在基类中已经定义了
myCommand.Fill(ds, ars);
dg.DataSource = ds.Tables[ars].DefaultView;
dg.DataBind();
}
catch
{
//报告错误
HttpContext.Current.Response.Write("<script>alert('绑定GridView无法通过!')script>");
}
//关闭数据库连接
objConn.Close();
}
.Net
|

1 评论:
谢谢了