Blob

Hello there
I'm using VB.Net 2005 and oracle 10g
I need to save an image at the field "BACKGROUND_IMAGE" on the table GS_USERS; so I wrote the code:
Dim conn As New OleDbConnection
Dim cmd As New OleDbCommand

Dim SQL As String

Dim FileSize As UInt32
Dim rawData() As Byte
Dim fs As FileStream

conn.ConnectionString = My.Settings.CPMSConnectionString

Try
fs = New FileStream(FileName, FileMode.Open, FileAccess.Read)
FileSize = fs.Length

rawData = New Byte(FileSize) {}
If rawData.Length / (1024 * 1024) > 1 Then '1MB
MessageBox.Show("Image so big.Please choose another one", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
Exit Sub
End If
fs.Read(rawData, 0, FileSize)
fs.Close()
conn.Open()

'SQL = "INSERT INTO file VALUES(NULL, ?FileName, ?FileSize, ?File)"
SQL = "UPDATE GS_USERS SET BACKGROUND_IMAGE=?File WHERE ID_USER=1 AND ID_COMPANY=1 AND ID_BRANCH=2"

cmd.Connection = conn
cmd.CommandText = SQL
'cmd.Parameters.Add("?FileName", strFileName)
'cmd.Parameters.Add("?FileSize", FileSize)
Dim PARAM As New OleDbParameter("?File", OleDbType.Binary)
PARAM.Value = rawData
PARAM = cmd.Parameters.Add(PARAM) '("?File", OleDbType.VarBinary, rawData.Length)

cmd.ExecuteNonQuery()

MessageBox.Show("File Inserted into database successfully!", _
"Success!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)

conn.Close()
Catch ex As Exception
MessageBox.Show("There was an error: " & ex.Message, "Error", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

Note that My.Settings.CPMSConnectionString is
'Provider=MSDAORA;Data Source=CPMS;Persist Security Info=True;Password=nagham;User ID=nagham

It gave me the exception:
'MSDAORA' failed with no error message available, result code: E_FAIL(0x80004005).

Any Help ?
[2419 byte] By [Nagham] at [2007-11-20 11:06:38]
# 1 Re: Blob
I would first of all question why you're using OleDb when the .NET Framework provides an Oracle-specific ADO.NET provider and Oracle themselves provide one too. I'd suggest that you switch providers first, then see if it still doesn't work.
jmcilhinney at 2007-11-10 3:08:18 >
# 2 Re: Blob
Ok...Now I'm using Oracle Provider so I replaced all "OLEDB" by "OracleClient"...so now I have this prob
ORA-01036: illegal variable name/number

Help plz
Nagham at 2007-11-10 3:09:29 >
# 3 Re: Blob
Please show us the exact code you're using now and show us exactly where the error occurs.
jmcilhinney at 2007-11-10 3:10:22 >