我建立一个迷你论坛网站..和我构建了几个表。我需要帮助与sql和数据关系表
1)用户 2)线程 3)评论 4)主题
我建立,将每次插入注释功能的用户将提交评论:
string saveComment = "INSERT INTO Comments(";
saveComment += " UsersID, ThreadsID, Date, Comments, CommentResponse";
saveComment += "Values('" + "','";// no idea what to insert in the UsersID
saveComment += "" + "','";// no idea what to insert in the ThreadsID
saveComment += DateTime.Now + "','";
saveComment += CommenttxtBox.Text + "','";
saveComment += commentResponseString + "')";
正如你可以看到这些字段具有UsersID和ThreadID,两者都通过外键连接到comments表。 现在,每次用户提交评论,我想我还需要插入到UsersID字段(这是评论表中的一个int,并且该字段在用户表中增加1)。我如何插入评论,并通知其他表不要增加用户ID 1.事实上,我希望它的用户ID保持不变,为每个用户提交评论..
我该怎么做?我需要插入到一个表中的几个字段(注释),但要告知其他表,它们实际上是提交评论的同一用户。
注:我不知道任何VB,只有C#和我使用Visual Studio 2010 asp.net
努力了解这里的问题,为什么插入到注释表中对其他表有什么影响? – iandayman 2011-05-13 11:42:44
因为他们通过链接 – 2011-05-13 12:38:51