...

View Full Version : adding a poll to a blog



a8le
04-23-2006, 07:51 PM
Hi all,

I have a blog table...



myBlog(Table)
BlogID (primary key)
Text(varchar 8000)
Date(datetime)


that has another associated table...



myBlogRatings(Table2)
RatingID (primary key)
Rating (float)
RatersIP (varchar 15)
BlogID (foreign key)


but now I want to be able to attach a poll to blog if needed...



myBlogPoll(Table3)
PollID (primary key)
PollQuestion (varchar 3000)
PollVote (int)
PollIpAddress (char 15)


Here's my question... I want to be able to add the poll at the same time as the blog. How do I do that? This means that if a certain checkbox is checked then all the poll at the same as the blog... if it is not then the only add the blog.

This is different from a rating because there is already a BlogID to reference. How do I add the blog's BlogID to the myBlogPoll as a foreign key. I am having a hard problem with this is because the BlogID is added to myBlog(Table1) as an identity (set to increment by 1).

So far I have found out that I can only edit one table at a time using TSQL. Is there a workaround that someone knows of? Javascript, ASP.net, anything.

Thanks in advance,

PS... I am trying to do the same thing as this forum is doing while taking in threads.

-a8le

a8le
04-24-2006, 07:33 PM
:confused: anyone?

NuneatonSam
04-25-2006, 10:30 PM
I have a similar system with my site, when a news post is created, it also creates a forum post and takes the postid from the forum and inserts it into a field called forumID in the news table. I think this is what your trying to do with your blog/poll thing?

I did it by firstly inserting the forum post and then taking the maximum id from the forum table and inserting it into the news table along with the news post.

Not sure if this is what you mean.

a8le
04-25-2006, 10:37 PM
maximum id

hmm... i didn't think about doing it that way. it is exactly what i mean.

can you provide me with some sample code? by the way i am using a stored procedure... can it still be accomplished?

-a8le

a8le
04-28-2006, 04:03 PM
NuneatonSam, thanx for the reply, I ended up editing the main table to include the polls.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum