Hello all - I'm having a problem with trying to load some encrypted
binary files into a SQLServer 2000 database. The files are going into
the database, but when I pull them out, they are 1 byte larger (328 ->
329) and when verified our tool says that the file is invlaid cause
it's been modified. I'm not sure if the bit is being added when they
are going in or coming out of the database.
Anyone have some suggestions on what I am doing wrong?
The help is appreciated.
UPLOAD CODE
_______________ _______________ _____
Dim con As New SqlConnection(C ONNECTION)
Dim da As New SqlDataAdapter( "Select * from TABLENAME", con)
Dim MyCB As SqlCommandBuild er = New SqlCommandBuild er(da)
Dim ds As New DataSet()
da.MissingSchem aAction = MissingSchemaAc tion.AddWithKey
con.Open()
da.Fill(ds, "TABLENAME" )
Dim fs As New FileStream("D:\ SOURCEFILE.enc" ,
FileMode.OpenOr Create, FileAccess.Read )
Dim MyData(fs.Lengt h) As Byte
fs.Read(MyData, 0, fs.Length)
fs.Close()
ds.Tables("TABL ENAME").Rows(1) ("FIELDNAME" ) = MyData
da.Update(ds, "TABLENAME" )
fs = Nothing
MyCB = Nothing
ds = Nothing
da = Nothing
con.Close()
con = Nothing
Response.Write( "File saved to database")
=============== =============== =============== =========
DOWNLOAD CODE
_______________ __________
Dim con As New SqlConnection(< CONNECTION>)
Dim da As New SqlDataAdapter( "Select * from TABLENAME", con)
Dim MyCB As SqlCommandBuild er = New SqlCommandBuild er(da)
Dim ds As New DataSet()
con.Open()
da.Fill(ds, "TABLENAME" )
Dim myRow As DataRow
myRow = ds.Tables("TABL ENAME").Rows(1)
Dim MyData() As Byte
MyData = myRow("FIELDNAM E")
Response.Buffer = True
response.addHea der("content-disposition",
"attachment;fil ename=FILENAME. enc")
Response.Conten tType = "applicatio n/octet-stream"
Response.Binary Write(MyData)
MyCB = Nothing
ds = Nothing
da = Nothing
con.Close()
con = Nothing
response.end()
+++++++++++++++ +++++++++++++++ +++++++++
binary files into a SQLServer 2000 database. The files are going into
the database, but when I pull them out, they are 1 byte larger (328 ->
329) and when verified our tool says that the file is invlaid cause
it's been modified. I'm not sure if the bit is being added when they
are going in or coming out of the database.
Anyone have some suggestions on what I am doing wrong?
The help is appreciated.
UPLOAD CODE
_______________ _______________ _____
Dim con As New SqlConnection(C ONNECTION)
Dim da As New SqlDataAdapter( "Select * from TABLENAME", con)
Dim MyCB As SqlCommandBuild er = New SqlCommandBuild er(da)
Dim ds As New DataSet()
da.MissingSchem aAction = MissingSchemaAc tion.AddWithKey
con.Open()
da.Fill(ds, "TABLENAME" )
Dim fs As New FileStream("D:\ SOURCEFILE.enc" ,
FileMode.OpenOr Create, FileAccess.Read )
Dim MyData(fs.Lengt h) As Byte
fs.Read(MyData, 0, fs.Length)
fs.Close()
ds.Tables("TABL ENAME").Rows(1) ("FIELDNAME" ) = MyData
da.Update(ds, "TABLENAME" )
fs = Nothing
MyCB = Nothing
ds = Nothing
da = Nothing
con.Close()
con = Nothing
Response.Write( "File saved to database")
=============== =============== =============== =========
DOWNLOAD CODE
_______________ __________
Dim con As New SqlConnection(< CONNECTION>)
Dim da As New SqlDataAdapter( "Select * from TABLENAME", con)
Dim MyCB As SqlCommandBuild er = New SqlCommandBuild er(da)
Dim ds As New DataSet()
con.Open()
da.Fill(ds, "TABLENAME" )
Dim myRow As DataRow
myRow = ds.Tables("TABL ENAME").Rows(1)
Dim MyData() As Byte
MyData = myRow("FIELDNAM E")
Response.Buffer = True
response.addHea der("content-disposition",
"attachment;fil ename=FILENAME. enc")
Response.Conten tType = "applicatio n/octet-stream"
Response.Binary Write(MyData)
MyCB = Nothing
ds = Nothing
da = Nothing
con.Close()
con = Nothing
response.end()
+++++++++++++++ +++++++++++++++ +++++++++
Comment