I connect to my access 2000 database via an ADO control in my VB 6 project. I want to provide a function to check if the database/recordset (there's only 1 table)is empty and delete all records in it if it isnt.
Any help would be great!
Thanx
I have done something similar before but don't have the code with me. This should work (if you have a primary key or other required field that cannot be empty it would be better)
dim cnDatabase as ADODB.Connection
set cnDatabase = New ADODB.connection
cnDatabase.connectionString = "provider = Microsoft.jet.OLEDB.3.51;Data Source = path to database"
dim temp as integer
cnDatabase.Open
sqlAction = "SELECT count(*) as myCount FROM tablename"
temp = cnDatabase.execute sqlAction
if temp > 0
sqlAction = "DELETE FROM tablename where required_field <> ''"
end if
cnDatabase.close
set cnDatabase = Nothing
uh, just use .Execute "DELETE FROM tablename" *******************************************************
[sub]General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.