I have an problem while copying database file to another folder.
In Brief i have develop an windows application in that one form is Data Backup and restore. Suppose i have run form separately then i will copy these file from one place to another but if i have loged in then use this form then it give me an error that File used by another process. I have try to close the sqlconnection and the current connectionstate is closed still i have an error.

i am using sqlexpress as sqlserver database.

Can anybody help me....

If you open a connection to the database, .NET actually opens multiple connections to that database (the connection pool). This is done to speed up future connections (in your program) that you might need. Even if you close all your connections, .NET maintains its open connections in case you might want to connect again.

You'll have to ensure that your software *never* connects to the database if you want to do a file copy.

Could you not write a stored procedure to do the backing up?

This might help.

Hi, Momerath
I am Trying to kill the 'sqlservr' process by using this code but still i have found an error access denied ,

Process[] Pro = Process.GetProcessesByName("sqlservr");
                    foreach (Process proce in Pro)

would anybody help me....is thier is any another way to copy files.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.