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
I need to be able to use https to connect to a server and
In a multi-server environment, users will be able to use a page to put,
I'm using a MS SQL Server db and use plenty of views (for use
I'm running NHibernate and SQL Server CE I am trying to use GUIDs as
I am building an ASP.NET web application that will use SQL Server for data
I need to use the following query but i am not able to use
I am not able to use the breakpoint in Studio with Javascript. I'm able
I am able to use the NHibernate Criteria API for an IN statement using
Requirements: Must be able to use C strings as well as C++ strings Fast

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.