473,888 Members | 1,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

inserting images from PictureBox in to the oracle database

1 New Member
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:
Expand|Select|Wrap|Line Numbers
  1. Imports System
  2. Imports System.IO
  3. Imports System.Windows.Forms
  4. Imports System.Data                 ' VB.NET
  5. Imports System.Drawing.Imaging
  6. Imports System.Collections
  7. Imports System.ComponentModel
  8. 'Imports System.Data.OracleClient    ' Oracle Client
  9. Imports Oracle.DataAccess.Client
  10. --------------------------------------------------------------------------------------------------------------
  11. Private Sub Insert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
  13.         Dim imagename As String
  14.         Dim conn As OracleConnection = New OracleConnection
  15.         ' Specify the connect string
  16.         conn.ConnectionString = "User Id=system;Password=tiger;Data Source=;"
  17.         ' Create the OracleCommand object
  18.         Dim cmd As OracleCommand = New OracleCommand
  19.         Dim bsize As Integer
  20.         Try
  21.             ' Open the connection
  22.             conn.Open()
  23.             MessageBox.Show("Connection to Oracle database established!")
  24.             'Console.WriteLine(" ")
  26.             If (imagename <> "") Then
  27.                 MessageBox.Show("Please load the Image")
  28.             Else
  29.                 Try
  30.                     Dim fls As System.IO.FileStream(imagename,IO.FileMode.Open, IO.FileAccess.Read)
  31.                     'fls = New FileStream(imagename, FileMode.Open, FileAccess.Read, FileShare.Read, bsize, True)
  32.                     'fls = New FileStream(imagename, FileMode.Open, FileAccess.Read)
  33.                     Dim blob(fls.Length - 1) As Byte
  34.                     fls.Position = 0
  35.                     fls.Read(blob, 0, System.Convert.ToInt32(fls.Length))
  36.                     fls.Close()
  37.                     Dim blobParameter As OracleParameter = New OracleParameter
  38.                     blobParameter.OracleDbType = OracleDbType.Blob
  39.                     blobParameter.ParameterName = "BlobParameter"
  40.                     blobParameter.Value = blob
  41.                     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 & "',)"
  42.                     ' Create the OracleCommand object
  43.                     cmd = New OracleCommand(cmdQuery)
  44.                     cmd.Connection = conn
  45.                     cmd.CommandType = CommandType.Text
  46.                     cmd.Parameters.Add(blobParameter)
  47.                     cmd.ExecuteNonQuery()
  48.                     MessageBox.Show("added to blob field")
  49.                     cmd.Dispose()
  50.                     conn.Close()
  51.                     conn.Dispose()
  52.                 Catch ex As Exception
  53.                     MessageBox.Show(ex.StackTrace)
  54.                 End Try
  55.             End If
  56.         Catch ex As Exception
  57.             MessageBox.Show(ex.StackTrace)
  58.         End Try
  60.    End Sub
Apr 2 '07 #1
0 1682

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 the images before inserting them as BLOBs. My problem is that (apart from being new to file stuff) my resize function returns a Resource ID which of course is not the same as the file handler that was passed to it, it's a reference to an image...
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 them in my VB.NET app using the picturebox control. I was really happy when I learned that you could use PNG images in VB.NET so your images could blend in with the form's background color. But, is PNG the ideal image format to use with these...
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 and dealt with some of the images which were in standard BMP format but most of the images are in some other format which is displayed ok in access application and can be copy/pasted to any image editor but when doubleclicking it doesn't open any...
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 something is not right because of the way I am using Application::DoEvents() (ref: http://www.codinghorror.com/blog/archives/000159.html and http://www.codinghorror.com/blog/archives/000370.html ), along with the fact that I get a crash when I try...
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 question. I have a web survey that I am working on and have successfully dynamically taken the info from a database, displayed it on the screen and then taken the users answers and inserted them into a
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 rectangles.The images are 2048x2048 pixels. It seems that I can find no efficient way to implement both zooming and panning. At present I have a panel with autoscroll set to true inside which there is
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: pictureBox.Image = new System.Drawing.Bitmap(this.openFileDialog.FileName);
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 and the main stream approach appears to be a panel/groupBox containing a pictureBox, resizing that pictureBox and using the PictureBoxSizeMode.StretchImage property. I don't want that. What I want is some "real" zoom effect. So I continued my search...
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 action=(Another_page).data is not insering into database.For ur kind infromation i m using oracle db and php for my application. sample code: <form action="welcome.php" method="post"> Name: <input type="text" name="name" /> Age: <input type="text" name="age" />
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.