Please help,
I'm trying to create a little app to archive data out of an Access Db. I've created a DSN that I can use MSQuery to connect to the mdb with and select/delete but when I try to connect from inside the .NET app it doesn't delete.
Here's the code I've got. Plz excuse, I am very new to VB programming.
Private Sub sArchive()
dt = dtpAchDate.Text
Dim sql1 As Object
sql1 = "delete from tblInvoice where InvDate < " & dt
Dim td
Dim cn1 As ADODB.Connection
cn1 = New ADODB.Connection
cn1.Open("DSN=LCAdata"
cn1.Execute(sql1)
cn1.Close()
cn1 = Nothing
End Sub
I'm getting dt from a "date/time picker" and the sql1 = delete from tblInvoice where InvDate < 1/1/2000 in the watch window. It is the sql1 watch that I can copy/paste into MSQuery and run the delete fine.
I've tried changing the Dim sql1 as Object to String, there is no difference, although I believe it should be String shouldn't it? Once past this little bump, I have a few more questions like, how to list all the tables in an Access db and run the same query against each of them, like I mentioned, I'm trying to create an archiving app (that the creator of the Access db should have created in the first place) if I'm on the wrong path, please suggest, I am very much open to suggestions.
Thanks for any assistance anyone can provide. If this is a repeat thread again, I apologize, I did search and didn't find anything close enough to answer my problem.
Thanks again.
I'm trying to create a little app to archive data out of an Access Db. I've created a DSN that I can use MSQuery to connect to the mdb with and select/delete but when I try to connect from inside the .NET app it doesn't delete.
Here's the code I've got. Plz excuse, I am very new to VB programming.
Private Sub sArchive()
dt = dtpAchDate.Text
Dim sql1 As Object
sql1 = "delete from tblInvoice where InvDate < " & dt
Dim td
Dim cn1 As ADODB.Connection
cn1 = New ADODB.Connection
cn1.Open("DSN=LCAdata"
cn1.Execute(sql1)
cn1.Close()
cn1 = Nothing
End Sub
I'm getting dt from a "date/time picker" and the sql1 = delete from tblInvoice where InvDate < 1/1/2000 in the watch window. It is the sql1 watch that I can copy/paste into MSQuery and run the delete fine.
I've tried changing the Dim sql1 as Object to String, there is no difference, although I believe it should be String shouldn't it? Once past this little bump, I have a few more questions like, how to list all the tables in an Access db and run the same query against each of them, like I mentioned, I'm trying to create an archiving app (that the creator of the Access db should have created in the first place) if I'm on the wrong path, please suggest, I am very much open to suggestions.
Thanks for any assistance anyone can provide. If this is a repeat thread again, I apologize, I did search and didn't find anything close enough to answer my problem.
Thanks again.