






















Today ,I created a script task of SSIS to upload pyisical files into data base.the core codes are as follows:
1
Dim fileStream As FileStream
2
Dim cmd As New OleDbCommand
3
Dim para As OleDbParameter
4
cmd.Connection = conn
5
cmd.CommandType = CommandType.Text
6
''Read file Content
7
fileStream = New FileStream(Path.Combine(attFilesFolder, dr("File_Name").ToString()), FileMode.Open)
8
Dim bytes(CInt(fileStream.Length)) As Byte
9
fileStream.Read(bytes, 0, CInt(fileStream.Length))
10
cmd.CommandText = "Update dbo.Sys_Pc_Attachment_Temp Set File_Content=@File_Content WHERE Old_Attachment_ID =" + dr("Old_Attachment_ID").ToString()
11
para = New OleDbParameter("@File_Content", OleDbType.Binary)
12
para.Value = bytes
13
para.Direction = ParameterDirection.Input
14
cmd.Parameters.Clear()
15
cmd.Parameters.Add(para)
16
cmd.ExecuteNonQuery()
17
But when i run it ,alwanys get a error:
"Must Declare Variable @File_Content"
one method to fix it: replcae @File_Content with ? in sal string.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。