Help with multiple recordsets and pulling an ID value (ASP)
I started this discussion when first developing my project and posted on the General Tab. I have figured out that issue (trying to get my Insert to work in ASP) but now am having trouble retrieving an ID value. It should be simple. I want to insert a new record into a single table and want to create a unique ID field. I am using SQL Server and tried the Identity setting but won't be able to have admin privileges which are required to set the ID. So, I'd like to just take the ID value from the last record and just add '1' to it to get a new unique ID manually. My INSERT portion was working, so I just decided to query the records to retrieve the last CatalogID and add '1' to get my new ID. But it's not working! I tried opening both a command and a recordset, but get various errors on invalid command use.
Any help would be great! I'm new to all of this!
I've posted a code snippet of what I thought I should do:
<%LANGUAGE = “VBSCRIPT” CODEPAGE=”65001”%)
<!--#include file=”Connections/CapConnect.asp”” -->
<%
If (Cstr(Request(“MM_insert”)) = “form1”) Then
Dim MM_editCmd
Dim MM_Lookup
Dim NextCatalogID
Set MM_Lookup = Server.CreateObject (“ADOB.Recordset”)
MM_Lookup.ActiveConnection = MM_CapConnect_STRING
MM_Liikup.Source = “Select CatalogID From dbo.tblCatalogItems ORDERBY CatalogID Ascending”
MMLookup.Open
MM_Lookup.MoveLast
NextCatalogID = MM_Lookup.Fields(“CatalogID”) + 1 'this is supposed to be my new ID value
Set MM_Lookup = Nothing
Set MM_editCmd = Server.CreateObject(“ADOB.Command”)
MM_editCmd.ActiveConnection = MM_CapConnect_STRING
MM_editcmd.CommandText = “INSET INTO dbo.tblCatalogItems (CatalogID, ModelName, Description, POCName, [POCPhone]) VALUES (NextCatalogID, ?,?,?,?)
MM_editcmd.Prepared = True
MM_edit.Parameters.Append MM_editcmd.CreateParameter(“param2”, 202, 1, 100, Request.Form(“modelname”) )
MM_edit.Parameters.Append MM_editcmd.CreateParameter(“param3”, 202, 1, 300, Request.Form(“Description”) )
…..
[Subject line edited by moderator to add server model]
