ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 17th, 2009, 02:11 PM
jhd1967 jhd1967 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 4 jhd1967 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 5 sec
Reputation Power: 0
ASP 1.0 - Get last id inserted to database @@IDENTITY

I am trying to get last id inserted to database and pass it to the next page as request query string. when inserted the record.

I am not sure why is not working..

Here is orginal code.

Code:
<% 
Dim MM_editAction 
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME")) 
If (Request.QueryString <> "") Then 
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString) 
End If 

' boolean to abort record edit 
Dim MM_abortEdit 
MM_abortEdit = false 
%> 
<% 
' IIf implementation 
Function MM_IIf(condition, ifTrue, ifFalse) 
If condition = "" Then 
MM_IIf = ifFalse 
Else 
MM_IIf = ifTrue 
End If 
End Function 
%> 
<% 
If (CStr(Request("MM_insert")) = "books") Then 
If (Not MM_abortEdit) Then 
' execute the insert 
Dim MM_editCmd 

Set MM_editCmd = Server.CreateObject ("ADODB.Command") 
MM_editCmd.ActiveConnection = MM_classifieds_STRING 
MM_editCmd.CommandText = "INSERT INTO news (title, subttitle) VALUES (?, ?)" 
MM_editCmd.Prepared = true 

MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 20, Request.Form("title")) ' adVarWChar 
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 20, Request.Form("subttitle")) ' adVarWChar MM_editCmd.Execute 
MM_editCmd.ActiveConnection.Close 

' append the query string to the redirect URL 
Dim MM_editRedirectUrl 
MM_editRedirectUrl = "view.asp" 
If (Request.QueryString <> "") Then 
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then 
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString 
Else 
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString 
End If 
End If 
Response.Redirect(MM_editRedirectUrl) 
End If 
End If 
%> 

I did:
SELECT @@IDENTITY as book

MM_editRedirectUrl = MM_editRedirectUrl & "?book=" & book_id())


Thank you

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > ASP 1.0 - Get last id inserted to database @@IDENTITY


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap