Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases 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 March 7th, 2004, 09:48 PM
Registered User
 
Join Date: Mar 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default getting identity field

hey guys wanted to know if anyone can help me
i just added a set of items using the addnew property
and i want to get the autonumber/identity field of the inputed record.
i tried calling it after the update statement with no luck
any clues on why its not picking up the value?

kj

strSQL ="SELECT * FROM SHPRULE"
Set objConn = Server.CreateObject("ADODB.Connection")
Set objCmd = Server.CreateObject("ADODB.Command")
Set objRS = Server.CreateObject("ADODB.Recordset")
objConn.Open strConnString
objCmd.ActiveConnection = objConn
objCmd.CommandText = strSQL

'-- Cursor Type, Lock Type

'-- ForwardOnly 0 - ReadOnly 1
'-- KeySet 1 - Pessimistic 2
'-- Dynamic 2 - Optimistic 3
'-- Static 3 - BatchOptimistic 4
objRS.Open objCmd, , 3, 3
objRS.Addnew
objRS.Fields("SRNAME") = request("field01")
objRS.Fields("MIN") = request("field03")
objRS.Fields("MAX") = request("field04")
objRS.Fields("SHPAMT") = request("field05")
objRS.Fields("SUPER") = request("field07")
objRS.Fields("PRIORITY") = request("field08")
objRS.Fields("SHPMETH") = request("field02")
objRS.Update


response.write objRS("SHPRULEID")

 
Old March 8th, 2004, 05:43 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

in global.asa
-------------
<SCRIPT LANGUAGE=VBScript RUNAT=Server>

Sub Application_OnStart
        Application("Con_ConnectionString") = "DSN=dsnname;DBQ=d:\database\databasename.mdb;Driv erId=281;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"
        Application("Con_ConnectionTimeout") = 15
        Application("Con_CommandTimeout") = 30
        Application("Con_CursorLocation") = 3
        Application("Con_RuntimeUserName") = ""
        Application("Con_RuntimePassword") = ""
End Sub

</SCRIPT>
------------------------------
<%
set cnn=Server.CreateObject("ADODB.Connection")
cnn.Open Application("Con_ConnectionString")
set rs=Server.CreateObject("ADODB.Recordset")
''''select com''''''
sql="SELECT * FROM SHPRULE"
rs.Open sql,cnn,1,3
response.write rs("SHPRULEID")
''''add com''''''''
sql="Insert into SHPRULE(your fields name) values(perticular values)"
cnn.Execute sql
''''update com '''''
same as above
use update command
%>


surendran
 
Old June 5th, 2004, 01:31 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

Not sure if this is closed out, but try calling the Id field before your update.






Similar Threads
Thread Thread Starter Forum Replies Last Post
IDENTITY Field ricespn SQL Server 2000 4 November 2nd, 2007 11:40 PM
Inserting a Value into an SQL Identity Field in VB vbmazza VB Databases Basics 1 April 27th, 2005 02:45 PM
SQL Server Identity field won't increment Ron Howerton VB.NET 2002/2003 Basics 8 April 22nd, 2004 12:14 PM
Identity field in the Data Row bmains ADO.NET 2 December 17th, 2003 04:34 PM





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