Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-02-10 : 19:37:48
|
| Brian writes "Hello,You posted this on 4guys...User Tips: Getting the ID of the Just Inserted Database Record here is the code block..Dim db,rcs,new_identity'Create a database connectionSet db = Server.CreateObject("adodb.connection")db.Open "DSN=MyDSN"'Execute the INSERT statement and the SELECT @@IDENTITYSet rcs = db.execute("insert into tablename (fields,..) " & _ "values (values,...);" & _ "select @@identity").nextrecordset'Retrieve the @@IDENTITY valuenew_identity = rcs(0)My question is can this be done with ADO as I have a block like this...rs.AddNew rs("memberID") = Session("memberID") rs("pic") = File.Binary rs("picName") = File.FileName rs("picFileSize") = File.Size rs("picType") = File.ContentType rs("picApproved") = "n" rs("picStatus") = "p" rs("uploadip") = Request.ServerVariables("REMOTE_ADDR") dtNow = Now() rs("dtUploaded") = FormatDateTime(dtNow, vbLongDate) & " " & FormatDateTime(dtNow, vbLongTime) 'rs("hash") = Hash 'rs("description") = Upload.Form("DESCR") rs.UpdateI use the above in other code but have this block from a 3rd party component and need the inserted id.Thanks," |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2002-02-10 : 20:45:17
|
| What ????Yes the ADO method works, but your question doesn't make sense. Are you saying you have a 3rd party component doing your insert for you ?In that case, the only way to get the identity back would be if the component made it available. If it doesn't, you might want to lean on the component author to make it available. Or write your own component.Damian |
 |
|
|
|
|
|