简体   繁体   中英

How to get affected record count from ConnectionObject.Execute() Method in vb.net

I am deleting entries in table using Connection object Execute() function. I am unable to get numbers of rows affected. Could someone help?

Dim db As ADODB.Connection
db = OpenDatabase(ConnectionString)
deleteExams = "delete from  [Table2] where  [PlanDate] < '" & sDate & "'"
db.Execute(deleteExams)  
db.Close()

the ADIDB execte method has a affected rows option see https://docs.microsoft.com/de-de/sql/ado/reference/ado-api/execute-method-ado-connection?view=sql-server-ver16

    Dim ObjAffectedrows As New Object
    db.Execute(deleteExams, ObjAffectedrows)
    Dim LongAfeected_Rows As Long = CLng(ObjAffectedrows)
    Dim LongAfeectedRows As Long
    Long.TryParse(ObjAffectedrows.ToString, LongAfeectedRows)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM