I am have problems with ado and the delete method. This is the error that I am getting:
runtime error 3251
This operation is not supported by the provider
I can add records to the access 2000 DB but I can't delete them. Everything worked fine with DAO but I wanted to try out ADO and I can't seem to get the delete to work.
The first sub is used to create open a Database and the second function is used to remove a record. Note: both of these subs are encapsulated into a class So DB is a class variable.
Any ideas would be appreciated.
I have references to "Microsoft DAO 3.6 object library" and " Microsoft Activex Data Objects 2.0 library"
'==================
Public Sub openDB(Optional provider As String)
'make sure there is a path to the database
Dim fso As FileSystemObject
If DBName = "" Then
MsgBox "Please enter a path to the database before trying to open it!"
Exit Sub
End If
'check to make sure the database file exists
Set fso = New FileSystemObject
If Not fso.FileExists(DBName) Then
MsgBox "The Database does not exist!", vbCritical, "File Not Found"
Exit Sub
End If
Dim sProvider As String
sProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
With DB
.Mode = adModeReadWrite
.ConnectionTimeout = 10
.CommandTimeout = 5
.CursorLocation = adUseClient
.Open sProvider & "Data Source=" & DBName & ";"
End With
End Sub
'=================
Public Sub rmNumber(ddate As Date)
Dim sql As String
Dim rs As ADODB.Recordset
sql = "SELECT * from LottoNumbers WHERE (Date = #" & ddate & "#)"
Set rs = New ADODB.Recordset
rs.Open sql, DB, , adCmdText
rs.Delete adAffectCurrent
rs.Update
'===================
Troy Williams B.Eng.
fenris@hotmail.com
runtime error 3251
This operation is not supported by the provider
I can add records to the access 2000 DB but I can't delete them. Everything worked fine with DAO but I wanted to try out ADO and I can't seem to get the delete to work.
The first sub is used to create open a Database and the second function is used to remove a record. Note: both of these subs are encapsulated into a class So DB is a class variable.
Any ideas would be appreciated.
I have references to "Microsoft DAO 3.6 object library" and " Microsoft Activex Data Objects 2.0 library"
'==================
Public Sub openDB(Optional provider As String)
'make sure there is a path to the database
Dim fso As FileSystemObject
If DBName = "" Then
MsgBox "Please enter a path to the database before trying to open it!"
Exit Sub
End If
'check to make sure the database file exists
Set fso = New FileSystemObject
If Not fso.FileExists(DBName) Then
MsgBox "The Database does not exist!", vbCritical, "File Not Found"
Exit Sub
End If
Dim sProvider As String
sProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
With DB
.Mode = adModeReadWrite
.ConnectionTimeout = 10
.CommandTimeout = 5
.CursorLocation = adUseClient
.Open sProvider & "Data Source=" & DBName & ";"
End With
End Sub
'=================
Public Sub rmNumber(ddate As Date)
Dim sql As String
Dim rs As ADODB.Recordset
sql = "SELECT * from LottoNumbers WHERE (Date = #" & ddate & "#)"
Set rs = New ADODB.Recordset
rs.Open sql, DB, , adCmdText
rs.Delete adAffectCurrent
rs.Update
'===================
Troy Williams B.Eng.
fenris@hotmail.com