static变量的一个问题
代码如下:
public static String photoId=""; protected void Page_Load(object sender, EventArgs e)
{
lblUserName.Text = Session["UserName"].ToString();
if (!IsPostBack)
{
this.GetFileData();
}
}
public void GetFileData()
{
using (OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("photo.mdb")))
{
conn.Open();
OleDbDataAdapter os = new OleDbDataAdapter("select * from tb_photo where photoUser='" + Session["UserName"].ToString() + "' order by id desc", conn);
DataSet ds = new DataSet();
os.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
GridView1.DataSource = ds.Tables[0];
GridView1.DataKeyNames = new String[] { "ID" };
GridView1.DataBind();
}
}
using (OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("photo.mdb")))
{
conn.Open();
OleDbDataAdapter oa = new OleDbDataAdapter("select * from tb_photo order by id desc",conn);
DataSet ds = new DataSet();
oa.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
photoId = (Convert.ToInt32(ds.Tables[0].Rows[0][0]) + 1).ToString();
}
else