Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3597794
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:09:47+00:00 2026-05-18T20:09:47+00:00

I was able to use SQL Filestream fine locally but when I try to

  • 0

I was able to use SQL Filestream fine locally but when I try to upload the files to a remote SQL server which uses SQL authentication, I get a Access Denied exception. Apparently, SQL Filestream only works with Windows Authentication (Integrated Security=true) and not with SQL Authentication which is what we currently have.

No one really uses Windows Authentication in production environment so I just want to know how to overcome this limitation. What’s the best practice?

    public static void AddItem(RepositoryFile repository, byte[] data)
{
    using (var scope = new TransactionScope())
    {
        using (var db = new MyEntities()) // DBContext
        {
            db.RepositoryTable.AddObject(repository);
            db.SaveChanges();
        }

        using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
        using (var cmd = new SqlCommand(string.Format("SELECT Data.PathName(), GET_FILESTREAM_TRANSACTION_CONTEXT() FROM dbo.RepositoryTable WHERE ID='{0}'", repository.ID), con)) // "Data" is the column name which has the FILESTREAM. Data.PathName() gives me the local path to the file.
        {
            cmd.Connection.Open();
            using (var reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    var path = reader.GetString(0);
                    var transactionContext = reader.GetSqlBytes(1).Buffer;
                    var fileStream = new SqlFileStream(path, transactionContext, FileAccess.Write);

                    fileStream.Write(contents, 0, contents.Length); // I get the error at this line.
                    fileStream.Close();
                }
            }
        }

        scope.Complete();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:09:48+00:00Added an answer on May 18, 2026 at 8:09 pm

    You indeed must use Integrated Authentication when using FILESTREAM:

    FILESTREAM Storage in SQL Server 2008

    You will need to make sure that the Windows account that the production application runs under has been added as a login in SQL Server and has been granted the same permissions as the SQL Authentication account the application currently uses.

    You must also ensure that the account has file system permissions to write to the FILESTREAM container.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was able to use SQL Filestream fine locally but when I try to
My job is the maintain one application which heavy use SQL server (MSSQL2005). Until
I'm using a MS SQL Server db and use plenty of views (for use
I've a user account on a development SQL express on a remote server. This
I have set up a remote server running SQl Server Web edition and full
I installed SQL Server 2005, and crated one user. I am able to connect
I can't use SQL Server CE 4.0 as a data provider in Visual Studio,
I use SQL Server 2008 and Entity framework 4.1 database first approach . Is
I am going to use SQL Server in my project, for that I want
Using an ADODB connection object, I am able to use SQL DDL with MS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.