@@identity formatting question

Results 1 to 3 of 3

Thread: @@identity formatting question

  1. #1
    Join Date
    Dec 1969
    Posts
    490

    Default @@identity formatting question

    hello,<BR><BR>I&#039;m trying to get this to work properly, but my code isn&#039;t formatted the way many of the examples are online. So I&#039;m having a little trouble. Here&#039;s what I have so far.<BR><BR>I&#039;m using this to try and pull the ID after the form is submitted...<BR><BR>session("JobNums") = InsertID & "," & session("JobNums")<BR><BR>And the here&#039;s what I&#039;m using to connect, insert the record and try to get the ID value...<BR><BR>MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & "); select @@identity"<BR><BR>Set MM_editCmd = Server.CreateObject("ADODB.Command")<BR>MM_editCmd .ActiveConnection = MM_editConnection<BR>MM_editCmd.CommandText = MM_editQuery<BR>MM_editCmd.Execute<BR>InsertID = MM_editCmd.Execute(0) <BR>MM_editCmd.ActiveConnection.Close<BR><BR>I&#03 9;m assuming it&#039;s in the second to last line. Not sure how to write it properly in this format. It inserts the record fine, but I don&#039;t get a value for my InsertID. I&#039;ve also tried changing the zero to my field name, but that didn&#039;t work either.<BR><BR>Any help or advice would be greatly appreciated. Thanks!<BR><BR>Wil<BR>

  2. #2
    Join Date
    Dec 1969
    Posts
    3,921

    Default Proper way to do this

    as well as avoid SQL injection security issues with your current methodology.<BR><BR>http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=99

  3. #3
    Join Date
    Dec 1969
    Posts
    490

    Default RE: Proper way to do this

    Unless there is a major security issue, I&#039;m not too worried since the information isn&#039;t critical. But I would like to try and keep the code I have, rather than starting from scratch if possible. The rest of the page is coded according to this layout and there&#039;s quite a bit of it. Although I will if it&#039;s absolutely necessary. I just feel like I&#039;ve got one or so lines written incorrectly and am hoping to solve it as is. Any ideas would be a major help. I&#039;ll definitely look into using that code in the future though.<BR><BR>Thanks<BR>Wil<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •