.NETGURU
how to solve file.copy problem
Messages   Related Types
This message was discovered on microsoft.public.dotnet.faqs.

Post a new message to this list...

tony
Hi there

when I want to copy a large file(>64K), I got error as follow:

the process cannot access the file, because it is being used by other
process

this is my code as follow
Try
File.Copy("C:\Program Files\Microsoft SQL
Server\MSSQL\Data\test.LDF", "C:\Program Files\Microsoft SQL
Server\MSSQL\Data\TEST2.LDF")
MessageBox.Show("OK")

Catch ex As Exception

MessageBox.Show("Error:" & ex.Message)
End Try

Thanks for any helpful.

Tony

Reply to this message...
 
    
Raghavendra T V
Hi Tony,

You are trying to copy the .ldf files which are used by MS SQL server.
You need to stop the MS SQL server on your machine which is running.
Only then you will be able to copy it.

I guess you are trying to take a backup of the MS SQL Database through
VB.NET code.
I would suggest you to make use of BACKUP DATABASE SQL command .

Thanks
Raghavendra
"tony" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
tony
Hi Raghavendra

Thank you for your information, and you are right, It is a MS SQL server
copy, so first I use sp_detech_db to detech the database (like you said,same
stop sql server) , and then make a copy, it is not only backup database, but
is make an absolute copy and save back in same SQL server with other
database name, it is dynamic copy, I only give the database name and let
vb.net make a total new copy with data,view,stored procedure, role ect
inside. I must use program to do it, it is required.

Do you have mre suggestion about that?
Do I have to run at command line to make a copy in vb.net?

Thanks

Tony
"Raghavendra T V" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Raghavendra T V
Hi Tony,

To restore the Database what you can do is take a backup of existing DB and
restore it with a different name.
This way you will have a copy of DB.

here is the sampe script to do this.

RESTORE DATABASE TaxReconDB_Prod
FROM DISK = 'D:\Tax\BackUp\TaxReconDB.dmp'
WITH MOVE 'TaxReconDB_Data' TO
'D:\Database\NJROS1D151DEV\MSSQL$NJROS1D151DEV\Data\TaxReconDB_Prod_Data.MDF
'
, MOVE 'TaxReconDB_Log' TO
'D:\Database\NJROS1D151DEV\MSSQL$NJROS1D151DEV\Data\TaxReconDB_Prod_Log.LDF'
, REPLACE

This works fine.Since i have used this in one of my project.

There is no need to run in Command line.(i guess u are thing of using isql
utility and point it to .sql file which contains the Scripts )

Thanks
Raghavendra

"tony" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.IO.File
System.Windows.Forms.MessageBox




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification