开发者

Vb.net File in use

开发者 https://www.devze.com 2023-01-13 03:46 出处:网络
I have a VB.Net program running on vista that says a file is in use but th开发者_StackOverflow社区e same program on XP does not have that error.Make sure you wrap disposable resources in Using stateme

I have a VB.Net program running on vista that says a file is in use but th开发者_StackOverflow社区e same program on XP does not have that error.


Make sure you wrap disposable resources in Using statement to ensure they are properly released:

Using conn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=c:\BAAW\Data\BAAW.mdf;Integrated Security=True;User Instance=True")
Using cmd As conn.CreateCommand()
    conn.Open()
    cmd.CommandText = "SELECT * FROM Employees"
    Using rdr As SqlDataReader = cmd.ExecuteReader()
        While rdr.Read()
            Console.WriteLine(rdr(0))
        End While
    End Using
End Using
End Using


Download Process Explorer - you can use that to determine which process has the file in question open.

0

精彩评论

暂无评论...
验证码 换一张
取 消