开发者

SQLFileStream exception "The network path was not found"

开发者 https://www.devze.com 2023-01-13 14:55 出处:网络
I am trying to insert a file into a database which uses SQL File Streaming. When I try to initialize the SqlFileStream object that I will be inserting with I receive a File Exception stating that the

I am trying to insert a file into a database which uses SQL File Streaming. When I try to initialize the SqlFileStream object that I will be inserting with I receive a File Exception stating that the network path could not be found.

The code in question is below:

using (SqlFileStream sqlStream = new SqlFileStream(filePathName.Value, fileToken.Value, FileAccess.Write))
                                {
                                    byte[] buffer = new byte[512 * 1024]; // 512Kb
                                    int bytesRead = fs.Read(buffer, 0, buffer.Length);
                                    while (bytesRead > 0)
                                    {
                                        sqlStream.Write(buffer, 0, bytesRead);
                                        bytesRead = fs.Read(buffer, 0, buffer.Length);
                                    }
                                }

The code fails at the first line when SqlFileStream is created. Below are my settings on how FILESTREAM is configured. At the database level I have set the Filestream access level to: "Full access enabled".

Enable FILESTREAM for Transact-SQL access: Checked

Enable FILESTREAM for file I/O streaming access: Checked

Windows share name: DVDB1FS

Allow remote clients to have streaming access to FILESTREAM data: Checked

Any suggestion on what may be causing this would be great. I have successfully used this exact same code in other environments without issue, so I know it must be a configuration issue of some sort. It may be important to note that if I try t开发者_开发百科o access the windows share //servername/DVDB1FS I also receive a "Network path was not found" error from Windows Explorer. If I access the share directly on a different server in a different environment (Test, Production) I receive an "Access is denied" error.


The different error messages mean its either a DNS or firewall issue. Determine what filePathName.Value is, and try to ping the hostname part of it from the server you cannot connect from. If the host name does not resolve its a DNS issue.

Its more likely a firewall issue. If that is the case see this MSDN article.


I got the same issue "network path could not be found". I think it was because I was trying to use FileStream with SQL Server Authentication (rather than Windows/NTFS authentication).

Microsoft documentation notes that: "SQL logins will not work with FILESTREAM containers."

https://msdn.microsoft.com/en-au/library/gg471497%28v=sql.130%29.aspx

The following Microsoft Connect article has some workarounds but I didn't try them.

https://connect.microsoft.com/SQLServer/feedback/details/416460/sql-server-authentication-filestream

0

精彩评论

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