开发者

Vb.net File in use

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜