Well it's been a while. It's awesome to see this place still thriving after all of these years.
I've got an error I cannot figure out after much online searching. Ive tried all sorts of things but am at a loss.Hoping someone here can help. The error I am getting is this
mscorlib.dll
Additional information: The process cannot access the file 'C:\dbfile.mdf' because it is being used by another process.
I am using Visual Studio 2017 VB.net. My Imports are:
The offending code:Code:Imports System Imports System.IO Imports System.IO.Compression Imports Microsoft.VisualBasic Imports System.Data.OleDb Imports System.Data Imports System.Data.SqlClient
Code:' NOTE THAT I EDITED THE FILENAME DOWN TO SOMETHING SIMPLE. IT ISNT REALLY IN THE ROOT DIR. 'I HAVE FULL PERMISSIONS WHERE IT RESIDES AND CAN INDEED COPY/DELETE/ETC IT PROGRAMATICALLY WHERE IT RESIDES connectionString = "Data Source=(localdb)\v11.0;Integrated Security=true;AttachDBFileName="C:\dbfile.mdf" connection = New System.Data.SqlClient.SqlConnection(connectionString) connection.Open() queryString = "SELECT * FROM dbo.myTable;" adapter = New SqlDataAdapter(queryString, connection) adapter.UpdateCommand = New SqlCommandBuilder(adapter).GetUpdateCommand() runParams = New DataSet() adapter.Fill(RunParams, "RunParams") runParams.Tables(0).Rows(0).Item(3) = 1 adapter.Update(runParams, "RunParams") connection.Close() adapter.UpdateCommand.Dispose() adapter.Dispose() runParams.Dispose() connection.Dispose() 'ALL WORKS PERFECT TO THIS POINT, BUT AFTER THIS POINT, IF I TRY TO DO ANYTHING WITH THE MDF FILE (COPY,MOVE, WHATEVER) I GET THE ERROR




Reply With Quote