SQL "cannot identify newly inserted rows" error Solution

Source: Internet
Author: User

In this case, access can be used, but SQL does not work. In Baidu's search solution, we found that N people encountered the same problem but could not find a solution: CopyCodeThe Code is as follows: Set rs = server. Createobject ("ADODB. recordset ")
Rs. Open "select * from T1", Conn, 1, 3
Rs. addnew ()
RS ("data") = "ABC123"
Rs. Update
RS ("data") = RS ("ID ")
Rs. Update
Rs. Close
Conn. Close

(Note: The ID field is the ID value (Identity )))

In a SQL database, you can only use the following methods:Copy codeThe Code is as follows: dim newid
Set rs = server. Createobject ("ADODB. recordset ")
Rs. Open "select * from T1", Conn, 1, 3
Rs. addnew ()
RS ("data") = "ABC123"
Rs. Update
Newid = RS ("ID ")
'Note that the value of the identifier must be 1 in cursortype and must be updated ().
Rs. Close
Rs. Open "select * from T1 where id =" & newid, Conn, 1, 3
RS ("data") = newid
Rs. Update
Rs. Close
Conn. Close

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.