Insert,Update BLOB colum value in asp.net

B

behdad

Hello folks,

i am trying to update a table in oracle database which is BLOB type in
vb here is my code:

Dim asciiString As String = TextBox1.Text
Dim ascii As Encoding = Encoding.ASCII
Dim baMsgIn As Byte() = ascii.GetBytes(asciiString)
Dim myQuery As String = ""
Dim oradb As String = */CONNECTION STRING/*
Dim OraConn As OracleConnection = New OracleConnection(oradb)
OraConn.Open()
Dim OraComd As OracleCommand
myQuery = "update pb_general_param set b_intro=:BlobParameter
where n_id=1"
Dim blobParameter As OracleParameter = New OracleParameter()
blobParameter.OracleDbType = OracleDbType.Blob
blobParameter.ParameterName = "BlobParameter"
blobParameter.Value = baMsgIn
OraComd = New OracleCommand(myQuery, OraConn)
OraComd.Parameters.Add(blobParameter)
OraComd.ExecuteNonQuery()
OraConn.Close()

but once i run this code it goes to "NOT RESPONDING" status and never
ends. do you have any idea what i should do about it?
 
A

Alexey Smirnov

Hello folks,

i am trying to update a table in oracle database which is BLOB type in
vb here is my code:

Dim asciiString As String = TextBox1.Text
        Dim ascii As Encoding = Encoding.ASCII
        Dim baMsgIn As Byte() = ascii.GetBytes(asciiString)
        Dim myQuery As String = ""
        Dim oradb As String = */CONNECTION STRING/*
        Dim OraConn As OracleConnection = New OracleConnection(oradb)
        OraConn.Open()
        Dim OraComd As OracleCommand
        myQuery = "update pb_general_param set b_intro=:BlobParameter
where n_id=1"
        Dim blobParameter As OracleParameter = New OracleParameter()
        blobParameter.OracleDbType = OracleDbType.Blob
        blobParameter.ParameterName = "BlobParameter"
        blobParameter.Value = baMsgIn
        OraComd = New OracleCommand(myQuery, OraConn)
        OraComd.Parameters.Add(blobParameter)
        OraComd.ExecuteNonQuery()
        OraConn.Close()

but once i run this code it goes to "NOT RESPONDING" status and never
ends. do you have any idea what i should do about it?

It looks correct, are you able to execute other updates against your
database?
http://www.oracle.com/technology/sample_code/tech/windows/odpnet/howto/anonyblock/index.html
 
A

Alexey Smirnov

yes other than this column it looks ok...

Hm, sorry, I have no Oracle here to test but if looking in the
internet I found a following trick
http://www.devart.com/dotconnect/oracle/docs/Lob.html

'Create temporary BLOB
Dim myLob As OracleLob = New OracleLob(myConnection,
OracleDbType.Blob)
Dim streamLength As Int32 = fs.Length
'Transfer data to server
myLob.Write(r.ReadBytes(streamLength), 0, streamLength)
'Perform INSERT
Dim myCommand As OracleCommand = New OracleCommand("INSERT INTO
Pictures (ID, PicName, Picture) VALUES(1,'pict1',:pictures)",
myConnection)
Dim myParam As OracleParameter = myCommand.Parameters.Add
("Pictures", OracleDbType.Blob)
myParam.OracleValue = myLob

Not sure if it helps but maybe you can try it
 
A

Alexey Smirnov

Thank you Alexey!
the link you gave me helped me...

Actually this is strange, why that technique was not listed on the
website of Oracle I've sent earlier
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top