Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My task is on remote server and csv file is also in the same server. When my task runs It throws below error. How do I fix?
I am getting following errors.
Cannot bulk load because the file "\\networkPath\d$\fileName.extension" could not be opened. Operating system error code 5(Access is denied.).


What I have tried:

I add and let SqlService account full control over folder.
Posted
Updated 8-Sep-17 6:34am
v2
Comments
Afzaal Ahmad Zeeshan 8-Sep-17 14:52pm    
Re-read the error, it says the access is denied. You need to have enough permissions in order to read the file.

1 solution

The error message is pretty clear. This is not a programming issue but a file access issue. I suspect that the file that you are trying to open is exclusive held open by another application.
 
Share this answer
 
Comments
[no name] 8-Sep-17 10:40am    
But this is the only program that access this file.
Graeme_Grant 8-Sep-17 10:43am    
Are you sure about that? Reboot your PC to check. Otherwise, if not a locked file condition, then it will be a security exception but it is unclear as the information that you have given is not enough to draw that conclusion.
[no name] 8-Sep-17 10:49am    
I think its security issue. Since I do not have much knowledge on system and network.
RedDk 8-Sep-17 12:48pm    
What program? This error "Cannot bulk load because the file ..." is typical of attempts at BULK LOAD under the guise of EXEC xp_cmdshell in some TSQL. Where is this leverage started?
RedDk 8-Sep-17 14:55pm    
Ok,

Well in this case then, as most comments seem to make explicit, the TSQL in this C# is concatenating strings and this is a no-no because, as insidious as it only seems to someone who has never actually run across it happening to them, SQL-Injection is likely to knock your database out.

Since I'm only a novice at best in C# though, I'd suggest stoking up SSMSE and going at the problem you've got in bad TSQL there. Trying to use CLR or create a CTE exercising UDF or UDP. MS SQL Server "Book on Line" help is SO excellent at giving examples that you will be able to determine where to go next.

And there's plenty of CLR Sto-Proc/UDP/UDF info right here in CP ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900