Hi,
I'm creating a new record for my db. Before I run my insert statement, I have to create a new ID value (primary key) for the new record. I'm trying to make this application ready for an empty db table.
For some reason, intNewID comes back empty even though I look for an empty recordset.
Any help would be greatly appreciated!
mD
I'm creating a new record for my db. Before I run my insert statement, I have to create a new ID value (primary key) for the new record. I'm trying to make this application ready for an empty db table.
Code:
dim objRS, strSQL, intNewID
strSQL = "select max(ID) + 1 as NEXTIDVAL " & _
"from MyTable"
set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn
if objRS.eof then
intNewID = 1
else
intNewID = objRS("NEXTIDVAL")
end if
response.Write("intNewID = " & intNewID)
objRS.close
set objRS = nothing
set strSQL = nothing
For some reason, intNewID comes back empty even though I look for an empty recordset.
Any help would be greatly appreciated!
mD