给你点帮助
兄弟,我也碰到类似的情况,是因为你没有注意到dnt_topics表中的lastpostid一直都在递增.在向表中新添内容时,先取出dnt_topics表中的lastpostid;将其lastpostid+1再写入数据表中.
方法也给你把:
int lastpostid = 0;
string selectlastpostid = "select top 1 lastpostid from dnt_topics ORDER BY lastpostid DESC";
SqlCommand cmd0 = new SqlCommand(selectlastpostid, conn1);
SqlDataReader dr3 = cmd0.ExecuteReader();
while (dr3.Read())
{
lastpostid = Convert.ToInt32(dr3["lastpostid"]);
}
lastpostid = lastpostid + 1;
嘿嘿,自己根据自己的代码修改一下.