Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is wrong w/this routine?! I can't delete!

Status
Not open for further replies.

cj92713696

Programmer
Nov 23, 2000
105
US
Private Sub issueDeleteByStore(strTableName As String, strStoreCode As String)
On Error GoTo errorMsg:

Dim strSQL As String
Dim lngCounter As Long

Dim sqlRS As New ADODB.Recordset

dbUtils.closeTbl sqlRS

strSQL = "SELECT * FROM " & strTableName & " WHERE " & strTableName & _
".StoreCode = '" & strStoreCode & "'"

sqlRS.Open strSQL, DE.fatsales_SQL.ConnectionString, adOpenStatic, adLockPessimistic

MsgBox sqlRS.RecordCount

If dbUtils.IsRSOpen(sqlRS) = True Then
If sqlRS.RecordCount > 0 Then
sqlRS.Delete
End If
End If

dbUtils.closeTbl sqlRS

sqlRS.Open strSQL, DE.fatsales_SQL.ConnectionString, adOpenStatic, adLockPessimistic
MsgBox sqlRS.RecordCount
dbUtils.closeTbl sqlRS

GlobalAccess.addDbHistory _
strStoreCode, _
"SQL Server database delete; table: " & strTableName & _
", store code: " & strStoreCode

Exit Sub

errorMsg:
MsgBox "issueDeleteByStore subroutine error: " & strSQL & vbCrLf & _
Err.Number & " - " & Err.Description, vbCritical, "Error"

End
End Sub
 
One other note.

After delete, I have the "adAffectGroup" option.
 
When creating an ADO recordset the recordcount property is usually -1 not the actual count.

If not (sqlRS.EOF and sqlRS.BOF ) then
sqlRS.Delete
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top