A Wrapper Class for DML Statements Using Visual Basic.NET - Adding code to add binary data for UPDATE command
(Page 5 of 7 )
The following is the code necessary for adding a column (of type binary) to the UPDATE command.
CaseCommandType.Update 'UPDATE command
Select Case m_dbObject.ConnectionType
Case DBConnType.MSSQL
m_SQL &= ColName & "=" & "@" & ColName & ","
'the following is same as the above case
Dim fileLength As Integer = pFile.ContentLength
If (fileLength = 0) Then
Throw New Exception("No information is available in selected File..try giving another existing filename")
End If
Dim FileByteArray(fileLength) As Byte
FileStream = UpFile.InputStream
FileStream.Read(FileByteArray, 0, fileLength)
'append this information to already existing arrays
If m_FileColNames Is Nothing Then
ReDim m_FileColNames(0)
ReDim m_FileByteArrays(0)
Else
ReDim Preserve m_FileColNames(UBound(m_FileColNames) + 1)
ReDim Preserve m_FileByteArrays(UBound(m_FileByteArrays) + 1)
End If
m_FileColNames(m_FileColNames.Length - 1) = ColName
m_FileByteArrays(m_FileByteArrays.Length - 1) = FileByteArray
Case Else
Throw New Exception("currently this library supports only SQL.NET Provider to upload files")
End Select
End Select
Next: Executing the DML command >>
More Visual Basic.NET Articles
More By Jagadish Chaterjee