我有以下代码:
更新
try
{
ArticleId = Request.QueryString["ArticleId"].ToString();
NewArticleTitle = Request.Form["ArticleTitle"].ToString();
NewArticleDate = Request.Form["ArticleDate"].ToString();
NewArticleBody = Request.Form["ArticleBody"].ToString();
string dpath = Server.MapPath(@"App_Data") + "/MySite.mdb";
string connectionstring = @"Data source='" + dpath + "';Provider='Microsoft.Jet.OLEDB.4.0';";
OleDbConnection con = new OleDbConnection(connectionstring);
string QuaryString = String.Format("update tblarticles set articletitle='{0}', articlebody='{1}', postdate='{2}' where articleid={3}", NewArticleTitle, NewArticleBody, NewArticleDate, ArticleId);
OleDbCommand cmd = new OleDbCommand(QuaryString, con);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "tbl");
con.Close();
Response.Redirect("ArticlesTable.aspx");
}
catch { }
ArticleId 是一个 AUTO INCREMENT(数字类型)当它到达这一行时 da.Fill(ds, "tbl");
,程序会继续捕获。我的问题是如何防止它,以便表格真正更新?希望得到帮助,谢谢!