Click here to Skip to main content
15,890,407 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string cs = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\SATDB.mdf;Integrated Security=True;User Instance=True";
            using (SqlConnection con = new SqlConnection(cs))
            {
                con.Open();
                SqlTransaction txn = con.BeginTransaction();
                string sql = "GET_FILESTREAM_TRANSACTION_CONTEXT(), SELECT Trial_Addmission.PathName() from Sat";
                SqlCommand cmd = new SqlCommand(sql, con, txn);
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    string filePath = rdr[0].ToString();
                    byte[] objContext = (byte[])rdr[1];
                    string Name = rdr[2].ToString();

                    SqlFileStream sfs = new SqlFileStream(filePath, objContext, FileAccess.Read);

                    byte[] buffer = new byte[(int)sfs.Length];
                    sfs.Read(buffer, 0, buffer.Length);
                    sfs.Close();
                }

                rdr.Close();
                txn.Commit();
                con.Close();
            }
        }
Posted
Comments
joshrduncan2012 4-Sep-13 12:33pm    
We won't guess at where the error is pointing to. Please tell us what line the error is pointing to.
Karim2Ahmed 4-Sep-13 12:41pm    
this line

SqlDataReader rdr = cmd.ExecuteReader();
joshrduncan2012 4-Sep-13 12:45pm    
That line is fine.
Torakami 4-Sep-13 12:33pm    
code seemz to b perfect ..check your other part in project
Karim2Ahmed 4-Sep-13 12:45pm    
What other part ??

1 solution

Your error is in this statement:
string sql = "GET_FILESTREAM_TRANSACTION_CONTEXT(), SELECT Trial_Addmission.PathName() from Sat";


The Microsoft documentation for GET_FILESTREAM_TRANSACTION_CONTEXT[^] shows that it must be used in a Select statement.

I've never seen anyone use GET_FILESTREAM_TRANSACTION_CONTEXT, so I can't help you write your code. See the Microsoft example for help.
 
Share this answer
 
v3

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