Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

File Copy fails giving Permission Denied Error

Hi All,

I'm maintaining a project in Visual Basic with backend as MS Access. Recordsets are opened using ADODB.Command object. There is no connection object used in the entire program, instead in all functions which returns recordset, it is created with

<Command Object>.ActiveConnection = <Connection String>

We are closing the connection using
<Command Object>.ActiveConnection = Nothing

Now, we've a function which does copy the entire database and store it with different name. Please, look at the following code

Dim cmd As New ADODB.Command
Dim RS As New ADODB.Recordset
Dim str As String

str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\AceQual.mdb;Persist Security Info=False"

cmd.ActiveConnection = str
cmd.CommandText = "select * from dbo_projects"
Set RS = cmd.Execute
cmd.ActiveConnection = Nothing

FileCopy "d:\acequal.mdb", "d:\acequal2.mdb"

It fails when it is trying to copy the file. It gives "Permission Denied" Error.

Kindly, suggest how to close the connection which is opened using Command object.
[1203 byte] By [Swarna Nagam] at [2007-11-11 6:38:54]