How to properly add new records to empty recordset manually?

后端 未结 3 1485
自闭症患者
自闭症患者 2021-01-02 01:15

How to add new records to a new & empty ADODB.Recordset manually?

Right now, here\'s what I\'m doing that isn\'t working:

Dim rs as ADODB.Records         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-02 02:03

    set rs = new ADODB.Recordset
    rs.Open "Select SomeFieldName, AnotherFieldName FROM MyTable", myConnection, adOpenDynamic, adLockOptimistic
    
    rs.AddNew
    rs("SomeFieldName").Value = "SomeValue"
    rs("AnotherFieldName").Value = 1
    rs.Update
    
    rs.AddNew
    rs("SomeFieldName").Value = "AnotherValue"
    rs("AnotherFieldName").Value = 2
    rs.Update
    
    rs.Close
    

提交回复
热议问题