Microsoft
Software
Hardware
Network
Question : asp.net SQL Filestream access is denied
Hi,
Using asp.net and sql 2008.
I am getting access is denied when trying to upload a file using filestream.
I have given access to the filegroup NDF file to the IUSR account and EVERYONE (as a test). Following is the code (which is fine), but it's some type of permissions issue obviously.
Dim buffer As Byte() = New Byte(CInt(FileUpload1.File
Content.Le
ngth) - 1) {}
FileUpload1.FileContent.Re
ad(buffer,
0, buffer.Length)
Dim objSqlCon As New SqlConnection(Configuratio
nManager.C
onnectionS
trings("Sk
illsDBConn
ectionStri
ng").Conne
ctionStrin
g)
objSqlCon.Open()
Dim objSqlTran As SqlTransaction = objSqlCon.BeginTransaction
()
Dim objSqlCmd As New SqlCommand("FileAdd", objSqlCon, objSqlTran)
objSqlCmd.CommandType = CommandType.StoredProcedur
e
Dim objSqlParam1 As New SqlParameter("@SystemNumbe
r", SqlDbType.Int)
objSqlParam1.Value = Session("candidate_id")
Dim objSqlParam2 As New SqlParameter("@FileType", SqlDbType.VarChar, 4)
objSqlParam2.Value = System.IO.Path.GetExtensio
n(FileUplo
ad1.FileNa
me)
Dim objSqlParam5 As New SqlParameter("@description
", SqlDbType.VarChar)
objSqlParam5.Value = txtDescription.Text
Dim objSqlParamOutput As New SqlParameter("@filepath", SqlDbType.VarChar, -1)
objSqlParamOutput.Directio
n = ParameterDirection.Output
objSqlCmd.Parameters.Add(o
bjSqlParam
2)
objSqlCmd.Parameters.Add(o
bjSqlParam
5)
objSqlCmd.Parameters.Add(o
bjSqlParam
1)
objSqlCmd.Parameters.Add(o
bjSqlParam
Output)
objSqlCmd.ExecuteNonQuery(
)
Dim Path As String = objSqlCmd.Parameters("@fil
epath").Va
lue.ToStri
ng()
objSqlCmd = New SqlCommand("SELECT GET_FILESTREAM_TRANSACTION
_CONTEXT()
", objSqlCon, objSqlTran)
Dim objContext As Byte() = DirectCast(objSqlCmd.Execu
teScalar()
, Byte())
Dim objSqlFileStream As New SqlFileStream(Path, objContext, FileAccess.Write)
objSqlFileStream.Write(buf
fer, 0, buffer.Length)
objSqlFileStream.Close()
objSqlTran.Commit()
bindData()
Answer : asp.net SQL Filestream access is denied
I needed to have Integrated Security = True in my DB connection in the web.config file, it worked then.
Random Solutions
How do you find a bug in a stored procedure?
what's the right way of loading multiple images in Loader?
extract element from string
how to create a count that starts at 001?
Problem with SOAP application on IIS "502 - Web server received an invalid response while acting as a gateway or proxy server"
Using GPP to set unique printers for each user on a Terminal Server
Timeout Expired max pool size was reached
Do Access Forms sometimes "Time-out" on opening if the underlying query is too complex?
Mofify the query
Regex to remove content from alt attribute in image tag