Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 5th, 2006, 03:41 AM
Registered User
 
Join Date: Dec 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to insert 2 tables with same auto increment ID

Hi all, I am having problem inserting the auto_increment id (FID) of table "TOPIC" to FTopicID of Table Msgs, I am using mysql as databse.The code works fine with MS Access Databse.Could any body help me.My codes are as follows:-

Dim rsTopic
set rsTopic = Server.CreateObject("ADODB.Recordset")
rsTopic.Open "Topic", objconn, adOpenForwardOnly, adLockOptimistic, adCmdTable

rsTopic.AddNew

If Request.Cookies("PMBVisit")("UserName") = "" Then
rsTopic("FGuest") = Request.Form("FName")
rsTopic("FTProfile") = False
Else
rsTopic("FName") = Request.Cookies("PMBVisit")("UserID")
rsTopic("FTProfile") = True
End If

rsTopic("FForumJoinID") = Request.Querystring("ForumID")
rsTopic("FSubject") = Request.Form("FSubject")
'the problem is here
Session("FTopicID") = rsTopic("FID")

rsTopic("FIcon") = Request.Form("TopicIcon")

rsTopic.Update
rsTopic.Close
set rsTopic = Nothing

'---------------------------------------------------------
' Dim NewID
' strSQL = "SELECT ID from table ORDER BY ID ASC LIMIT 1"
' "SELECT MAX(FID) from Topic"
' set NewID = Server.CreateObject("ADODB.Recordset")

' NewID.set strSQL, objConn



Dim rsMsgs
set rsMsgs = Server.CreateObject("ADODB.Recordset")
rsMsgs.Open "Msgs", objConn, adOpenForwardOnly, adLockOptimistic, adCmdTable

rsMsgs.AddNew

If Request.Cookies("PMBVisit")("UserName") = "" Then
rsMsgs("FMsgGuest") = Request.Form("FName")
rsMsgs("FMsgEmail") = Request.Form("FEmail")
rsMsgs("FMsgProfile") = False
Else
rsMsgs("FMsgName") = Request.Cookies("PMBVisit")("UserID")
rsMsgs("FMsgEmail") = Request.Cookies("PMBVisit")("Email")
rsMsgs("FMsgProfile") = True
End If

rsMsgs("FMsg") = Request.Form("FMsg")

rsMsgs("FTopicID") = Session("FTopicID")
rsMsgs("FMsgForumID") = Request.QueryString("ForumID")
rsMsgs("FMsgIP") = Request.ServerVariables("LOCAL_ADDR")

rsMsgs.Update
rsMsgs.Close
set rsMsgs = Nothing

:)

 
Old December 7th, 2006, 05:00 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

This is the .NET thread, not the Classic ASP thread.

Anyway.

You can not insert values into an auto increment field, mySQL and MS SQL Server for that matter both will throw an error if you do.

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature





Similar Threads
Thread Thread Starter Forum Replies Last Post
Regarding auto increment of id Rajesh225 ASP.NET 1.0 and 1.1 Basics 1 June 27th, 2007 05:35 PM
Auto increment prad_a MySQL 3 April 7th, 2007 05:47 AM
How To insert auto increment ID to other table ibrhaim ASP.NET 1.0 and 1.1 Professional 4 December 8th, 2006 02:26 PM
How to auto increment ? Shawn Mohan SQL Server 2000 2 June 22nd, 2006 03:00 AM
auto increment? hosefo81 PHP Databases 1 February 2nd, 2004 03:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.