-
Operating system error code 3(The system cannot find the path specified.).
I have a page that I've built that does a bulk insert from a file that is stored on a web server. When the user clicks on the submit button, they receive the following error:
Operating system error code 3(The system cannot find the path specified.).
I have made sure that the SQL server has admin rights to the path of the folder that has the file uploaded to it (I even added the specific SQL server user to the admin rights) and it still won't work. The SQL server is 2000 and the web server is Windows Server 2003. Any ideas as to what may be causing this? I've read several different posts on several different forums and it seems that the consensus has been that it's a permissions issue. I think that with all that I've done, that the permissions are set up correctly but I may be wrong.
Thank you
Doug
-
It sounds like your permissions aren't right as you suspect. I think you are setting the wrong permissions though, at least that is how I am interpreting your post.
It sounds like you have the following scenario:
- User uploads a file from a webpage to the webserver
- On the server the webpage then performs a bulk insert into SQL server from the file that was uploaded
If this is the case and you are getting the error on the web page then the permissions issue lies with the account your webpage is running under. The easiest way to troubleshoot this would be to run your page under the debugger and catch the error, when you do examine the path it is trying to find and ensure it is valid. If so, then you need to set the permissions for the user account that IIS ( or more correctly the app-pool) is running under to have permissios to the path.
-
permissions
J,
What I did this morning was to wipe the slate clean as far as permissions go and create a new user on the web server in question. I then made sure with aspnet_regiis that the new user had permissions to execute with asp.net. I then made sure that the default application pool is using the newly created account and I'm still receiving the error. I'm not sure what I'm missing, but I'm obviously missing something.
-
Are you able to attach the debugger and see the path to confirm it is correct? Another tool you could use is FileMon. This would allow you to see the file access and the user/process that is trying to access it.
-
Debugging
I do have the following lines in my code:
DebugLabel.Text = SavePath
DebugLabel.Text = DebugLabel.Text + "<br />"
and I'm seeing that it is the correct path.
-
Then I would use FileMon to confirm the user that is trying to access the file:
http://technet.microsoft.com/en-us/s.../bb896642.aspx
-
Filemon
john,
Since I've never used filemon before, I'm not really sure what I should be looking for here but I see that there are some path not found errors with csrss.exe. What should I be looking for with the filemon log?
-
The easiest thing is to focus on either the process you believe is trying to access the file and limit to only information from that process or on the folder/file that it is trying to acesss.
So set a filter to either filter by "process Name is XXX" or "Path begins with XXX" and then look for your error.
-
Filemon
I've taken a look through my filtered results and don't see anything on the server side that's showing me a username/pwd of the process that's trying to access the file. The process should be default.aspx.vb as that's where the page should be trying to initialize the sql bulk insert. As I said, I see the csrss.exe but again, I'm not seeing a username/pwd in there either.
-
actually, the process should be w3svc.exe or dllhost.exe or w3wp.exe
to see the username you'd need to add the Username column to the output (richt click the headers and choose "select columns" then add it.
-
Filemon
John,
Ok I did as you suggested and looked at the process headers, I filtered all except for w3wp.exe and see the ChangeNotify as the "Other result" and looked at the process and it is the correct user, which in this case it's MSBWEB3 as the machine name and CustomASP as the user. So maybe because it's a machine name and not a domain name that this is causing the problem? The SQL server is a separate machine, but since the Default Application Pool is trying to open the file on the web server, I'd think that this should work, correct?
-
Yes, if MSBWEB3\CustomASP is trying to access the file and has rights to that file and that folder that it is in then you should be okay. Another thing to check is that you are properly closing the file after writing it out. It could be that you haven't closed out the file after the upload and the system doesn't know it's there when you try to access it to perform the batch.
Just to be clear, the database is not trying to access the file in any way, correct? I presume you are opening the file and generating the batch within code, if not then it may be a different isue.
-
John,
Here's the code I have for the page from the default.aspx.vb side
Code:
Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub Submit1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit1.Click
Dim SaveLocation As String = Server.MapPath("Data") & "\upload.txt"
If UploadFile(SaveLocation) Then
'the file was uploaded: now try saving it to the database
SaveToDatabase(SaveLocation)
End If
End Sub
Private Function UploadFile(ByVal SavePath As String) As Boolean
Dim fileWasUploaded As Boolean = False 'indicates whether or not the file was uploaded
'Checking if the file upload control contains a file
If Not File1.PostedFile Is Nothing And File1.PostedFile.ContentLength > 0 Then
Try
'checking if it was .txt file BEFORE UPLOADING IT!
'You used to upload it first...but the file could be a virus
If File1.FileName.EndsWith(".txt") = False Then
'The file is not the expected type...do not upload it
'just post the validation message
message.Text = "Please submit a text file."
Else
'The file is a .txt file
'checking to see if the file exists already
'If it does exist Deleting the existing one so that the new one can be created
If IO.File.Exists(SavePath) Then
IO.File.Delete(SavePath)
End If
'Now upload the file (save it to your server)
File1.PostedFile.SaveAs(SavePath)
'After saving it check to see if it exists
If File.Exists(SavePath) Then
'Upload was sucessful
message.Text = "Thank you for your submission"
fileWasUploaded = True
Else
'the file was not saved
message.Text = "Unable to save the file"
End If
End If
Catch Exc As Exception
'We encountered a problem
message.Text = Exc.Message + " " + Exc.StackTrace
End Try
Else
'No file was selected for uploading
message.Text = "Please select a file to upload"
End If
Return fileWasUploaded
End Function
Private Sub SaveToDatabase(ByVal SavePath As String)
Try
Dim sqlQueryText As String = _
"BULK INSERT dialerresults " + _
"FROM '" & SavePath & "' " + _
"WITH ( FIELDTERMINATOR = ',' , ROWTERMINATOR = '\n' )"
' and bulk import the data:
'If ConfigurationManager.ConnectionStrings("Dialerresults") IsNot Nothing Then
'Dim connection As String = ConfigurationManager.ConnectionStrings("Dialerresults").ConnectionString
Dim connection As String = "data source=10.2.1.40;initial catalog=IVRDialer;uid=xxxxxx;password=xxxxxxx;"
'I removed the DataTable declaration because you're not using it.
Using con As New SqlConnection(connection)
con.Open()
' execute the bulk import
Using cmd As New SqlCommand(sqlQueryText, con)
DebugLabel.Text = SavePath
DebugLabel.Text = DebugLabel.Text + "<br />"
cmd.ExecuteNonQuery()
End Using
End Using
'Else
'message.Text="ConfigurationManager.ConnectionStrings('Dialerresults') is Nothing!"
'End If
Catch ex As Exception
message.Text = ex.Message + ex.StackTrace
End Try
End Sub
End Class
You can see that when I said that the SQL command was basic that I wasn't kidding. Theres not much to it. I will though make sure that the customasp user has access to the root of the directory and NOT just the directory itself. Does it look as though the file is being closed correctly?
Last edited by dougancil; 05-17-2010 at 02:38 PM.
-
Is the database on the same machine as the web page?
By the way, when posting code I'd be sure to XXXX out any userid's and passwords.
-
John,
I went back and edited that post after realizing that I hadn't removed the user name and pwd to the database. No, the database is on another server within my network. The web server is 10.2.1.66 and as you can see the sql server is 10.2.1.40.
Similar Threads
-
By Vince Silvia in forum Enterprise
Replies: 0
Last Post: 10-09-2001, 08:40 AM
-
By Crispin Wright in forum VB Classic
Replies: 2
Last Post: 08-26-2001, 06:08 PM
-
Replies: 1
Last Post: 05-03-2001, 09:03 AM
-
By SINNI in forum VB Classic
Replies: 0
Last Post: 03-21-2001, 09:00 AM
-
By SINNI in forum VB Classic
Replies: 0
Last Post: 03-21-2001, 09:00 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|