Hi,
This is HARSHAD,
I am creating a project in VB.NET
for managing details like photos of criminals.
but i am facing problems in converting a image in to filestream so that it can be inserted in to the oracle 10g database using BLOB variable type.
if you can help me it will be very helpful..
This is my code:
--------------------------------------------------------------------- - Imports System
-
Imports System.IO
-
Imports System.Windows.Forms
-
Imports System.Data ' VB.NET
-
Imports System.Drawing.Imaging
-
Imports System.Collections
-
Imports System.ComponentModel
-
'Imports System.Data.OracleClient ' Oracle Client
-
Imports Oracle.DataAccess.Client
-
--------------------------------------------------------------------------------------------------------------
-
Private Sub Insert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
-
-
Dim imagename As String
-
Dim conn As OracleConnection = New OracleConnection
-
' Specify the connect string
-
conn.ConnectionString = "User Id=system;Password=tiger;Data Source=;"
-
' Create the OracleCommand object
-
Dim cmd As OracleCommand = New OracleCommand
-
Dim bsize As Integer
-
Try
-
' Open the connection
-
conn.Open()
-
MessageBox.Show("Connection to Oracle database established!")
-
'Console.WriteLine(" ")
-
-
If (imagename <> "") Then
-
MessageBox.Show("Please load the Image")
-
Else
-
Try
-
Dim fls As System.IO.FileStream(imagename,IO.FileMode.Open, IO.FileAccess.Read)
-
'fls = New FileStream(imagename, FileMode.Open, FileAccess.Read, FileShare.Read, bsize, True)
-
'fls = New FileStream(imagename, FileMode.Open, FileAccess.Read)
-
Dim blob(fls.Length - 1) As Byte
-
fls.Position = 0
-
fls.Read(blob, 0, System.Convert.ToInt32(fls.Length))
-
fls.Close()
-
Dim blobParameter As OracleParameter = New OracleParameter
-
blobParameter.OracleDbType = OracleDbType.Blob
-
blobParameter.ParameterName = "BlobParameter"
-
blobParameter.Value = blob
-
Dim cmdQuery = "INSERT into ARREST values('" & TextBox1.Text & "','" & TextBox4.Text & "','" & TextBox6.Text & "','" & TextBox8.Text & "','" & TextBox11.Text & "','" & ComboBox1.Text & "','" & ComboBox2.Text & "','" & ComboBox3.Text & "','" & TextBox12.Text & "','" & TextBox13.Text & "','" & ComboBox4.Text & "','" & ComboBox5.Text & "','" & ComboBox10.Text & "','" & TextBox15.Text & "','" & TextBox18.Text & "','" & TextBox19.Text & "','" & TextBox23.Text & "','" & TextBox25.Text & "','" & TextBox26.Text & "','" & TextBox27.Text & "','" & TextBox28.Text & "',:BlobParameter,:BlobParameter ,'" & TextBox7.Text & "','" & ComboBox6.Text & "','" & TextBox10.Text & "','" & ComboBox7.Text & "','" & TextBox39.Text & "','" & TextBox54.Text & "','" & TextBox41.Text & "','" & TextBox43.Text & "','" & TextBox44.Text & "','" & TextBox45.Text & "','" & ComboBox14.Text & "','" & ListBox1.Text & "',)"
-
' Create the OracleCommand object
-
cmd = New OracleCommand(cmdQuery)
-
cmd.Connection = conn
-
cmd.CommandType = CommandType.Text
-
cmd.Parameters.Add(blobParameter)
-
cmd.ExecuteNonQuery()
-
MessageBox.Show("added to blob field")
-
cmd.Dispose()
-
conn.Close()
-
conn.Dispose()
-
Catch ex As Exception
-
MessageBox.Show(ex.StackTrace)
-
End Try
-
End If
-
Catch ex As Exception
-
MessageBox.Show(ex.StackTrace)
-
End Try
-
-
End Sub
0 1584 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mat |
last post by:
Hi,
I have a system that uploads images as BLOBs in a database. I also
have a function that I use to resize uploaded images before saving as
files. I would like to combine these two by resising...
|
by: Andrew Christiansen |
last post by:
Hey all. The images I create in photoshop with semi-transparent pixels (for
instance in Photoshop text with a dropshadow with a transparent canvas) I've
been saving in PNG format and then using...
|
by: Alan |
last post by:
Hi,
I'm converting a database application from Access 97 to C#/SQL Server. Old
database contains some images in OLE fields. I've figured out that there's
OLE header preceeding actual image data...
|
by: Marcus Kwok |
last post by:
I have written a class (Windows Form) in Managed C++ that accepts an
array of image filenames and will display them sequentially. All images
will be the same size. I got it to work, but I know...
|
by: clinttoris |
last post by:
Hello,
If someone could help me it would be appreciated as I am not having
much luck.
I'm struggling with my asp code and have some questions relating to asp
and oracle database.
First...
|
by: =?Utf-8?B?U3BlZWR5?= |
last post by:
Hi there,
I am currently writing an application where one inspects images and
annotates certain features. Thus, one has to zoom in (4x) and pan around. The
features are marked with little red...
|
by: san123456789 |
last post by:
Hi,
Im using a MS SQL server to store images... Im creating a windows form application using C#.
I need to store and retrieve images from the database.
This is my code to store images:
...
|
by: Amnu |
last post by:
Hi there,
I've been told to write a custom control using C#.NET ( 2.0 ).
This control should be able to display images and give access to zoom functionality. I've visited numerous How-To pages...
|
by: boss1 |
last post by:
Hi all,
i m having a problem with inserting data in oracle db.
When i use form action =(call self page) then data is inserting properly.But problem with when using form...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |