Discuz!NT 2.5 正式版 下载
beta、RC版升级补丁
Comsenz 招聘信息
首届Discuz!NT 模板大赛圆满结束
著名音乐网站SoGua网、分贝网
采用Discuz!NT搭建社区
FIFA Online2官网论坛使用Discuz!NT
游戏城寨论坛使用Discuz!NT搭建
第二届优秀版主评选揭晓
Discuz!NT 2.5正式开源 Discuz!NT文档中心
用户整合说明文档
Discuz!NT亮相微软Tech-Ed 2007
Discuz!NT情景搞笑短片抢先看
1/1页1 跳转到查看:893
发新话题 回复该主题

数据库.dnt_topics[急][求救]

数据库.dnt_topics[急][求救]

各位大侠:



我从另一个表想要把一些贴子导入到.dnt_topics,dnt_post1表中结果不成功啊
老提示重复:
不能在具有唯一索引 'list' 的对象 'dbo.dnt_topics' 中插入重复键的行。

TOP

 

给你点帮助

兄弟,我也碰到类似的情况,是因为你没有注意到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;
嘿嘿,自己根据自己的代码修改一下.
程序人生!

TOP

 
1/1页1 跳转到
发表新主题 回复该主题