Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
WrapperImpersonationContext context = new WrapperImpersonationContext(System.Environment.MachineName, "guest", "");
                        context.Enter();

              SqlConnection sqlConnection2 = new SqlConnection("Data Source=" + DBConn.ConnectionProperties.ServerName + ";Database=JMSIMG;User ID=" + DBConn.ConnectionProperties.DBUsername + ";Password=" + DBConn.ConnectionProperties.DBPassword + ";Trusted_Connection=False;Integrated Security = true");

                        SqlCommand sqlCommand2 = sqlConnection2.CreateCommand();
                        sqlCommand2.CommandText = "Select GET_FILESTREAM_TRANSACTION_CONTEXT() As TransactionContext";
                        sqlConnection2.Open();
                       SqlCommand("Select GET_FILESTREAM_TRANSACTION_CONTEXT() As TransactionContext")).Tables[0].Rows[0][0];
                        byte[] transactionContext1 = (byte[])sqlCommand2.ExecuteScalar();
Error !!
C#
SqlFileStream sqlFileStream1 = new SqlFileStream(filePath1, transactionContext1, FileAccess.Write)
Error !!!
C#
byte[] ProductImage = grbPictureBox1.BinaryValue;
sqlFileStream1.Write(ProductImage, 0, ProductImage.Length);
sqlFileStream1.Close();
transactionScope.Complete();
context.Leave();

I'm using SQL SERVER 2008 R2 , filestream enabled as Database
I'm using filestream for storing images.The code I used is given above . Database located in a normal Win 7 PC .The code is working on the same PC which the Database is located but giving "Access Denied " error from rest of the PC's in the network. I'm Using Workgroup not Domain network here . I'm Struck on this for some days please help..
Posted
Updated 19-Feb-14 21:39pm
v2
Comments
Frank T. Clark 20-Feb-14 16:51pm    
It looks like the permissions on filePath1 do not allow other computers/users to access the file. If they can't see it in Windows Explorer then they do not have permissions.
Jackson K T 21-Feb-14 5:43am    
So how can we set permission to filepath1 ?
Frank T. Clark 21-Feb-14 8:29am    
Basic IT question. The answer can be quite complex. Assuming you have a simple network, you must be using a UNC path of the format \\computer\share\folder\file. You must have file sharing installed and enabled on your computer. You must have a share set up with write permissions. You must have the file permissions set for write access. Most of all, you need an IT/knowledgeable person who knows these things.​ Or you need to ask many more detailed questions.

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