.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> VB.Net >> Post New QuestionBookmark and Share Subscribe to Forum

cannot delete sdf file of sql server ce connection

Posted By: Raymond     Posted Date: May 27, 2011    Points:5   Category :VB.Net
Dear all,

I have below statement for sql server ce connection. When delete the sdf file, it prompt error:

The process cannot access the file 'C:\Documents and Settings\xxx\My Documents\StockTake.sdf' because it is being used by another process.

Dim conn As New SqlCeConnection
conn.ConnectionString = "Data Source=" & DIR & stocktakefile & ";Persist Security Info=False"
conn.Open()
Dim cmd As New SqlCeCommand("select * from stocktake", conn)
Dim reader As SqlCeDataReader

reader = cmd.ExecuteReader()

While (reader.Read())

.............................

reader.Close()
cmd.Dispose()
conn.Close()

System.IO.File.Delete(Dir & stocktakefile) // Cannot delete???



Responses
Author: Maverick             
Posted Date: May 27, 2011     Points: 20   

Hello,

Make copy always property of that sdf file to true.

Hope it helps.



Thanks,
Maverick


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend