M
Michael Maes
Hello,
I'm trying to INSERT all kind of files in a SQL Server 2000 Table.
These files are e-mail attachments (.PDF, .XLS, .DOC, ....).
Using the code below, returns an IConvertible error.
The DataType of the field is 'Text'. Should this be 'Image'?
What am I missing?
Michael
Dim sqlCONN As New SqlConnection(global.sdc)
Dim scmd As New SqlCommand("UPDATE tblEmailAttachments SET
attachment=@attachment WHERE emailID = " & emailID & " AND fileName = " &
fileName, sqlCONN)
Dim fs As New System.IO.FileStream(SourceFilePath, IO.FileMode.Open,
IO.FileAccess.Read)
Dim b(fs.Length() - 1) As Byte
fs.Read(b, 0, b.Length)
fs.Close()
Dim P As New SqlParameter("@attachment", SqlDbType.Text, b.Length,
ParameterDirection.Input, False, 0, 0, Nothing, DataRowVersion.Current, b)
scmd.Parameters.Add(P)
sqlCONN.Open()
scmd.ExecuteNonQuery()
sqlCONN.Close()
I'm trying to INSERT all kind of files in a SQL Server 2000 Table.
These files are e-mail attachments (.PDF, .XLS, .DOC, ....).
Using the code below, returns an IConvertible error.
The DataType of the field is 'Text'. Should this be 'Image'?
What am I missing?
Michael
Dim sqlCONN As New SqlConnection(global.sdc)
Dim scmd As New SqlCommand("UPDATE tblEmailAttachments SET
attachment=@attachment WHERE emailID = " & emailID & " AND fileName = " &
fileName, sqlCONN)
Dim fs As New System.IO.FileStream(SourceFilePath, IO.FileMode.Open,
IO.FileAccess.Read)
Dim b(fs.Length() - 1) As Byte
fs.Read(b, 0, b.Length)
fs.Close()
Dim P As New SqlParameter("@attachment", SqlDbType.Text, b.Length,
ParameterDirection.Input, False, 0, 0, Nothing, DataRowVersion.Current, b)
scmd.Parameters.Add(P)
sqlCONN.Open()
scmd.ExecuteNonQuery()
sqlCONN.Close()