S
Shawn
Hi.
I'm trying to save an image into a Sybase DB. The field (image_1) is of type
"Blob". I have found two examples that I've tried, but no luck so far.
Here is what I have done:
Example 1:
strSqlImage = _
"UPDATE" & _
" table_1" & _
" SET" & _
" image_1 = ?" & _
" WHERE" & _
" id = " & ID
cmd = New OleDbCommand(strSqlImage, conn)
Dim fileStream As New System.IO.FileStream(strFilePath, IO.FileMode.Open,
IO.FileAccess.Read)
Dim b(fileStream.Length) As Byte
fileStream.Read(b, 0, b.Length)
fileStream.Close()
Dim P As New OleDbParameter("@Picture", OleDbType.VarBinary, b.Length,
Data.ParameterDirection.Input, False, 0, 0, Nothing,
Data.DataRowVersion.Current, b)
cmd.Parameters.Add(P)
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
The code gave me this error:
"[Native Error code: 1622][DataDirect ADO Sybase Provider] Type '"
Example 2:
Dim FileLength As Integer
Dim UpFile As System.Web.HttpPostedFile = txtFile.PostedFile
FileLength = UpFile.ContentLength
Dim FileByteArray(FileLength) As Byte
Dim StreamObject As System.IO.Stream = UpFile.InputStream
StreamObject.Read(FileByteArray, 0, FileLength)
strSqlImage = _
"UPDATE" & _
" table_1" & _
" SET" & _
" image_1 = ?" & _
" WHERE" & _
" id = " & ID
conn.Open()
cmd = New OleDbCommand(strSqlImage, conn)
cmd.Parameters.Add(New OleDbParameter("@Picture",
OleDbType.Binary)).Direction = System.Data.ParameterDirection.Input
cmd.Parameters("@Picture").Value = FileByteArray
cmd.ExecuteNonQuery()
conn.Close()
The code gave me this error:
"Conversion failed for command parameter[0]'@ Picture' because the data
value overflowed the type used by the provider."
I'm using "Sybase ASE OLE DB Provider" to connect to the DB. The Sybase DB
is version 11.9
I'm stuck here so please help me!
Thanks,
Shawn
I'm trying to save an image into a Sybase DB. The field (image_1) is of type
"Blob". I have found two examples that I've tried, but no luck so far.
Here is what I have done:
Example 1:
strSqlImage = _
"UPDATE" & _
" table_1" & _
" SET" & _
" image_1 = ?" & _
" WHERE" & _
" id = " & ID
cmd = New OleDbCommand(strSqlImage, conn)
Dim fileStream As New System.IO.FileStream(strFilePath, IO.FileMode.Open,
IO.FileAccess.Read)
Dim b(fileStream.Length) As Byte
fileStream.Read(b, 0, b.Length)
fileStream.Close()
Dim P As New OleDbParameter("@Picture", OleDbType.VarBinary, b.Length,
Data.ParameterDirection.Input, False, 0, 0, Nothing,
Data.DataRowVersion.Current, b)
cmd.Parameters.Add(P)
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
The code gave me this error:
"[Native Error code: 1622][DataDirect ADO Sybase Provider] Type '"
Example 2:
Dim FileLength As Integer
Dim UpFile As System.Web.HttpPostedFile = txtFile.PostedFile
FileLength = UpFile.ContentLength
Dim FileByteArray(FileLength) As Byte
Dim StreamObject As System.IO.Stream = UpFile.InputStream
StreamObject.Read(FileByteArray, 0, FileLength)
strSqlImage = _
"UPDATE" & _
" table_1" & _
" SET" & _
" image_1 = ?" & _
" WHERE" & _
" id = " & ID
conn.Open()
cmd = New OleDbCommand(strSqlImage, conn)
cmd.Parameters.Add(New OleDbParameter("@Picture",
OleDbType.Binary)).Direction = System.Data.ParameterDirection.Input
cmd.Parameters("@Picture").Value = FileByteArray
cmd.ExecuteNonQuery()
conn.Close()
The code gave me this error:
"Conversion failed for command parameter[0]'@ Picture' because the data
value overflowed the type used by the provider."
I'm using "Sybase ASE OLE DB Provider" to connect to the DB. The Sybase DB
is version 11.9
I'm stuck here so please help me!
Thanks,
Shawn