Forum Moderators: open
You also don't have a FROM clause in your SQL statement.
I've seen the AS/400 database use the "@" symbol in the field name, but when I access that DB through ASP I need to drop the "@" and use the remaining chars as the ASP field name.
So, something like @ID in the AS/400 would be referenced as ID in ASP.
Give it a try.
Also, I'm not familiar with the DECLARE statement in this context. If you want to alias the field you can do is:
SELECT IDENTITY as IDORDER
FROM?
also, you don't need a from clause when calling @@identity.
my statements work fine; they all execute perfectly. the only problem i'm having is calling the @idOrder variable in asp. i was told something about using rs(0) with NOCOUNT, but i'm not entirely sure what that does.
SQL = "SET NOCOUNT ON; INSERT INTO [Order] (<columns here>)" & _
"VALUES (<values here>);" & _
"DECLARE @idOrder int; " & _
"SELECT @idOrder = @@identity; " & _
"UPDATE [OrderItem] SET idOrder = @idOrder WHERE idShoppingCart = " & idShoppingCart
set rs = conn.execute(SQL)
set rs = rs.NextRecordset
ordernumber = rs(0)
there, this is the whole statement. but, when i try this, i get a "type mismatch" error the rs(0) line. any thoughts? thank you in advance.
but, i do like your idea about the max(@idOrder), that might just work. i will try it out, and let you know. thank you very much.
i could not it to work, so after the main glob of statement execution, i added a "SELECT MAX(idOrder) as idNew FROM [Order]" and it works now.
i now dread the day where 2 people almost simultaneously place an order and the numbers get messed up. the odds are definitely with me, but it only takes once.