Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21238

counting records before deleting

$
0
0
Can anyone tell me ? how should i count the rows before delete the rows . when it come to the msgbox line it says item cannot be found in the recordset collection .or let me know any better way
Code:

Private Sub btDelete_Click()
Dim con As New ADODB.Connection
Dim Sqlcount As String
Dim Sql As String
Sqlcount = "Select Count(StoreID) From Inventory"
Sql = "DELETE FROM INVENTORY"
    If Not OpenConnection(con) Then
      Call MsgBox("Connection is not open", vbInformation, "Connectivity issue")
      Exit Sub
    End If
 MsgBox con.Execute(Sqlcount).Fields("StoreID").Value
con.Execute "Delete from inventory"
con.Close
Set con = Nothing
Call MsgBox("Record deleted ", vbInformation)
End Sub


Viewing all articles
Browse latest Browse all 21238

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>