-
January 14th, 2021, 12:48 PM
#1
VB application Uploading files(Blobs) into Oracle
Hello everyone I am new on here.
I have a simple application that uploads text files into oracle as blobs. These files have text in them.
I just noticed that if the text has french accent characters in it then when I upload the blobs those characters get corrupt.
I also doubled check the Encoding for the database and it appears correct. We are using an Oracle Database.
I am thinking that I some how need to encode the Blob I am uploading.
NLS_CHARACTERSET AL32UTF8 0
NLS_NCHAR_CHARACTERSET AL16UTF16 0
How to I go about adding UTL 8 encoding when I am uploading a blob.
Code:
conn.Open()
Dim command1 As New OracleCommand(SQLStr, conn)
Try
'conn.Open()
If conn.State = ConnectionState.Open Then
Console.WriteLine("Connected to database!")
' provide read access to the file
Dim Fs As FileStream = New FileStream(SourceLoc,
FileMode.Open, FileAccess.Read)
' Create a byte array of file stream length
Dim ImageData As Byte()
ReDim ImageData(Fs.Length)
'Read block of bytes from stream into the byte array
Fs.Read(ImageData, 0, System.Convert.ToInt32(Fs.Length))
'Close the File Stream
Fs.Close()
SQLStr = SQLStr & " Update " & TableName & " Set BIN_DATA = :1 where FILENAME = :2"
' Set command to create Anonymous PL/SQL Block
Dim command As New OracleCommand() '(StrSQL, conn)
command.CommandText = SQLStr
command.Connection = conn
' Since executing an anonymous PL/SQL block, setting the command type
' as Text instead of StoredProcedure
command.CommandType = CommandType.Text
Dim param1 As OracleParameter = command.Parameters.Add("BIN_DATA", OracleDbType.Blob) 'BIN_DATA (BLOB)
param1.Direction = ParameterDirection.Input
' Assign Byte Array to Oracle Parameter
param1.Value = ImageData
Dim param2 As OracleParameter = command.Parameters.Add("FILENAME", OracleDbType.Varchar2) 'FILENAME
param2.Size = 50
param2.Direction = ParameterDirection.Input
' Assign Byte Array to Oracle Parameter
param2.Value = File
command.ExecuteNonQuery()
command.Dispose()
'Console.WriteLine("Image file inserted to database from " + SourceLoc)
lblValidateSuccessfull.Text = "File has been uploaded to " & RBOracleServer.SelectedValue & " database. "
'Next
End If
Catch ex As Exception
Console.WriteLine(ex.ToString)
End Try
-
January 14th, 2021, 12:49 PM
#2
Re: VB application Uploading files(Blobs) into Oracle
Thank you for any information you can give me.
-
January 18th, 2021, 10:37 AM
#3
Re: VB application Uploading files(Blobs) into Oracle
I am just wondering if maybe I am not explaining myself well. Lot's of looks but not any comments
-
January 18th, 2021, 12:24 PM
#4
Re: VB application Uploading files(Blobs) into Oracle
Try the sister vb site which has a more active VB forum.
https://www.vbforums.com/forumdispla...sual-Basic-NET
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|