|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hey guys iv been learning visual basic for a week now and iv managed to creat a register/login, unaccesable pages and a guestbook. Iv been working hard on building a verry basic forum. there is only one forum desplaying threads. I have 2 tables is my Forum.mdb tblPosts and tblTopics. I have a "Topic_ID" field that is supposed to link with the "ID" field (be the same) under tblTopics, this is how i desplay the data.
Now were im stuck is were iv made the "Post New Topic/Thread" form, The User name, topic name, date, views and replys need to go into tblTopics wile the comments need to go into tblPosts, also somhow i need to get the newly created ID from tblTopics and insert it into the Topic_ID in tblPosts. As i said iv oly just started so ill probly need a half long answer =], thanks heaps guys. |
|
#2
|
||||
|
||||
|
Hi, and welcome to the forums. I am willing to help but you will need to provide more information. Can you show us any code you have so far. Can you show us your table structure. Finally, what database are you using, is it SQLServer? If you are using SQLServer then you can grab the ID of the record you just created by using @@IDENTITY.
The more info you provide the better the answer you will receive. |
|
#3
|
|||
|
|||
|
Re
Ahh iv figured it out now, i got searching for a few hours and gathered bits and pieces of code and figured it out. thanks for trying to help tho ;]
|
|
#4
|
||||
|
||||
|
Quote:
Glad you figured it out. If you have the time, it may be worthwhile posting a brief description of your solution just in case anyone else has a similar issue. For anyone who is interested, this link is a great explanation of how to return the id of the record that has just been created using SQLServer. |
|
#5
|
|||
|
|||
|
Well im using a MS Access DB and what i did was just after i added new data into one table i then set the ID to a variable if thats how you spell it, then closed the recordset then opened it with a new SQL holding my new tables properties then used that variabal to insert it like this --->
rsAddComments.AddNew rsAddComments.Fields("Topic_Name") = Request.Form("txtTopic") rsAddComments.Fields("User_Name") = Request.Form("txtUserName") rsAddComments.Fields("Date") = Request.Form("txtDate") rsAddcomments.Fields("Views") = 0 rsAddcomments.Fields("Replys") = 0 rsAddComments.Update TopicsID = rsAddcomments("ID") rsAddComments.Close rsAddComments.Open strSQL2, adoCon rsAddComments.AddNew rsAddComments.Fields("PUser_Name") = Request.Form("txtUserName") rsAddComments.Fields("Comments") = Request.Form("txtComments") rsAddComments.Fields("Topic_ID") = TopicsID rsAddComments.Update Ect... |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Heeeelp! =] |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|