If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > In search of help please

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-22-08, 09:01
daveyy daveyy is offline
Registered User
 
Join Date: Oct 2004
Location: Edinburgh Scotland
Posts: 23
In search of help please

I am trying to construct an insert record statement on an ASP page to insert data into Oracle. I need to bring back the unique ID which is created in the database as the data goes in. This is not working. I have attached the relevant code below. I've created the session variable and dragged it onto the new page, but I'm getting error on line 115 (red text). Could someone have alook at this and offer some suggestions. Maybe I need to start again.

Code:
If (Not MM_abortEdit) Then
    ' execute the insert
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = "SET NOCOUNT ON;" & MM_editQuery & ";SELECT @" & "@IDENTITY AS Ident"
    Set rsLastIdent = MM_editCmd.Execute
    if NOT rsLastIdent.EOF then
    strLastIdent = rsLastIdent.Fields.Item("Ident").Value
         ' place the new record ID in a session variable called "NewID"
    Session("NewID") = strLastIdent
    End If
    MM_editCmd.ActiveConnection.Close 
	End If
	End If
Reply With Quote
  #2 (permalink)  
Old 04-22-08, 09:20
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
You cannot open a recordset on an execute connection object.
Code:
myRecordset.Open "SELECT field1 FROM table1", myOpenConnection
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 04-22-08, 10:26
daveyy daveyy is offline
Registered User
 
Join Date: Oct 2004
Location: Edinburgh Scotland
Posts: 23
Quote:
Originally Posted by georgev
You cannot open a recordset on an execute connection object.
Code:
myRecordset.Open "SELECT field1 FROM table1", myOpenConnection
Many thanks for a speedy reply georgev but I don't understand your reply. Are you saying that this is not possible?
Reply With Quote
  #4 (permalink)  
Old 04-22-08, 11:37
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
It is entirely possible, but you are confusing your methodology.

To perform an insert, update or delete, you execute the SQL command against the connection.
Code:
myConnection.Execute(SQL)
To perform SELECT statements, you must open a recordset object against the connection
Code:
myRecordset.Open(SQL, myConnection)
Then you can iterate through the resultset.

Hope this helps

Please note all the baove code is pseudo code
__________________
George
Twitter | Blog
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On