"Already in use" Error when trying to read in a sql script
"Already in use" Error when trying to read in a sql script
"Already in use" Error when trying to read in a sql script
"Already in use" Error when trying to read in a sql script
"Already in use" Error when trying to read in a sql script
"Already in use" Error when trying to read in a sql script "Already in use" Error when trying to read in a sql script "Already in use" Error when trying to read in a sql script "Already in use" Error when trying to read in a sql script "Already in use" Error when trying to read in a sql script "Already in use" Error when trying to read in a sql script "Already in use" Error when trying to read in a sql script "Already in use" Error when trying to read in a sql script
"Already in use" Error when trying to read in a sql script "Already in use" Error when trying to read in a sql script
"Already in use" Error when trying to read in a sql script
Go Back  Xtreme Visual Basic Talk > > > "Already in use" Error when trying to read in a sql script


Reply
 
Thread Tools Display Modes
  #1  
Old 10-05-2006, 02:35 PM
Caeanis Caeanis is offline
Freshman
 
Join Date: Jan 2005
Posts: 40
Default "Already in use" Error when trying to read in a sql script


I am getting the error "The process cannot accesss the file 'C:\Documents and Settings\...etc' because it is being used by another process."

The funny thing is, this only happens when I compile and publish my windows form app. If I run it in debug mode out of the ide this does not happen. Below is the code I'm using to pull the sql script file I'm trying to read:

<vb.net>
Dim NewQuery, st, NewLine As String
Dim i As Integer
Clipboard.Clear()
Dim Total As Integer
i = 0
Dim vIndex As Array = Split(txtParam.Text, ",")
If cboType.SelectedIndex > -1 Then
fPath = fPath & cboType.Text & "\" & myFile
Else
fPath = fPath & myFile
End If
Dim thisLine As String
Dim fs As New IO.FileStream(fPath, FileMode.Open)
Dim sr As New IO.StreamReader(fs)
NewQuery = ""
NewLine = ""
Do While sr.Peek <> -1
thisLine = sr.ReadLine()
If InStr(thisLine, "E") > 0 Then
st = "ET "
Else
st = "et "
End If

</vb.net>

Any help would be apreciated.

Caeanis
- Es bonita la venganza cuando el dios la conceda
Reply With Quote
  #2  
Old 10-06-2006, 05:14 PM
Caeanis Caeanis is offline
Freshman
 
Join Date: Jan 2005
Posts: 40
Default

Anybody? Anybody? Bueler? Bueler? Bueler? Bueler?
Reply With Quote
  #3  
Old 10-07-2006, 12:36 AM
Cags's Avatar
Cags&quot;Already in use&quot; Error when trying to read in a sql script Cags is offline
Contributor

* Expert *
 
Join Date: Jul 2003
Location: Leicestershire, England
Posts: 710
Default

Did you call the FileStream and StreamReaders .Close() methods? It's possible your the one locking the file.
__________________
I don't suffer from insanity, I enjoy every minute of it.
http://www.tib-studios.co.uk
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
&quot;Already in use&quot; Error when trying to read in a sql script
&quot;Already in use&quot; Error when trying to read in a sql script
&quot;Already in use&quot; Error when trying to read in a sql script &quot;Already in use&quot; Error when trying to read in a sql script
&quot;Already in use&quot; Error when trying to read in a sql script
&quot;Already in use&quot; Error when trying to read in a sql script
&quot;Already in use&quot; Error when trying to read in a sql script &quot;Already in use&quot; Error when trying to read in a sql script &quot;Already in use&quot; Error when trying to read in a sql script &quot;Already in use&quot; Error when trying to read in a sql script &quot;Already in use&quot; Error when trying to read in a sql script &quot;Already in use&quot; Error when trying to read in a sql script &quot;Already in use&quot; Error when trying to read in a sql script
&quot;Already in use&quot; Error when trying to read in a sql script
&quot;Already in use&quot; Error when trying to read in a sql script
 
&quot;Already in use&quot; Error when trying to read in a sql script
&quot;Already in use&quot; Error when trying to read in a sql script
 
-->