I'm newbie to .net and currently learning to use BLOB to insert image into database
What i'm facing is i dont know what is going wrong to make me continue getting this error:
An unhandled exception of type 'System.Data.Ol eDb.OleDbExcept ion' occurred in system.data.dll
Hope to get some direction from all senior
the following is my code:
_______________ _______________ _______________ _______________ ___ - Private Function OpenConn() As Boolean
-
myCN = New OleDb.OleDbConnection
-
Dim sConnString = "Provider=MSDAORA.1;User ID=123;Password=123;Data Source=test" '
-
myCN.ConnectionString = sConnString
-
myCN.Open()
-
OpenConn = True
-
-
End Function
-
________________________________________________________________
-
Private Sub CloseConn()
-
If myCN.State = ConnectionState.Open Then
-
myCN.Close()
-
End If
-
End Sub
-
_________________________________________________________________
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
Dim openDlg As OpenFileDialog = New OpenFileDialog
-
openDlg.Filter = "All Files|*.*|Bitmaps|*.bmp|GIFs|*.gif|JPEGs|*.jpg"
-
Dim filter As String = openDlg.Filter
-
openDlg.Title = "Open a Bitmap File"
-
If (openDlg.ShowDialog() = DialogResult.OK) Then
-
curFileName = openDlg.FileName
-
TextBox1.Text = curFileName
-
With PictureBox1
-
.Image = Image.FromFile(openDlg.FileName)
-
.SizeMode = PictureBoxSizeMode.CenterImage
-
-
End With
-
-
End If
-
End Sub
-
________________________________________________________________
-
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
-
-
OpenConn()
-
-
Dim cmd As OleDbCommand
-
Dim fs As FileStream
-
-
fs = New FileStream(curFileName, FileMode.Open, FileAccess.Read) ' Read a bitmap contents in a stream
-
Dim b(fs.Length - 1) As Byte
-
fs.Read(b, 0, b.Length)
-
fs.Close()
-
-
cmd = New OleDbCommand("INSERT INTO test (filename, filesave) Values ('" + TextBox1.Text.Substring(TextBox1.Text.LastIndexOf("\") + 1+ "','?')", myCN)
-
cmd.Parameters.Add("filesave", OleDbType.VarBinary)
-
cmd.Parameters.Item(0).Value() = b
-
cmd.ExecuteNonQuery()
-
CloseConn()
-
-
MsgBox("New Record inserted.")
-
End
-
End Sub
-
__________________________________________________________________
I'm thinking is it my last few line (SqlCommand) going wrong?
but don't know how to modify it
Please give me some direction, thanks in advance
** im using microsoft visual studio .net 2003 and 1.1 framework
5 1553 Plater 7,872
Recognized Expert Expert
What line throws the exception?
What line throws the exception?
hello, Plater
the line throws the exception is :
cmd.ExecuteNonQ uery()
so i think it may caused by the incorrect command text
Thanks.
Plater 7,872
Recognized Expert Expert
Yes, I don't believe your command paramaters and sql string are correct.
The exception message should have had more details about WHAT it didn't like?
Yes, I don't believe your command paramaters and sql string are correct.
The exception message should have had more details about WHAT it didn't like?
there are just displayed :
An unhandled exception of type 'System.Data.Ol eDb.OleDbExcept ion' occurred in system.data.dll
Plater 7,872
Recognized Expert Expert
Well that is a managed exception, so there is more to it then that. Try debugging it?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Thierry |
last post by:
Hello,
I do have a mysql database with a BLOB column. What is the proprest way
to read this column ?
Thx,
Thierry
|
by: sams |
last post by:
Iam posting this after trying many tutorials in the NG and failing to
retrieve the blob out of a record. So please bear with me before
before you pull the water hose or flame throwers ......
I can upload a Jpeg image file perfectly. Iam using this snippet to do
that..
<!-- addpic.php snippet !-->
....
$file = fopen($_FILES, "rb");
|
by: NotGiven |
last post by:
I am researching the best place to put pictures. I have heard form both
sides and I'd like to know why one is better than the other.
Many thanks!
|
by: adam |
last post by:
Hi, I have an issue that i just cant seem to figure out hope some one
can help.
right i am getting people to input the own images directly into a blob
within a mysql database. then on the next page i want to display the
image with in a nicely formatted html table so i can put the image
where i choose on the page
*this code is only putting the image on the top of the page and wont
let me output any other text etc*
|
by: Corrine |
last post by:
I am trying to pass a temporary BLOB that I've created in Java, to a
PLSQL function that modifies it, and then to retrieve this modified
value back to Java, all using JDBC.
I can't figure out how to get the modified BLOB object back to Java
after the PLSQL block has finished executing.
I do:
BLOB bl = BLOB.createTemporary(db,true,BLOB.DURATION_SESSION);
| |
by: Ellen K |
last post by:
Hi all,
It was my understanding (Please correct me if I'm wrong on this!) that
BLOB data actually reside on their own separate pages and a BLOB field
only holds a pointer to the location of the actual data, therefore the
BLOB data per se would not get written to the log, only the pointer
would be written.
If log shipping works by applying the transaction log to the standby
database, then what happens to the BLOB data?
|
by: matt |
last post by:
hello,
im doing my first ASP.NET app that inserts & retrieves files from
Oracle (no need for a discussion on *that*!).
i learned first-hand of the somewhat awkward technique for inserting
binary data into an Oracle BLOB column via ADO.NET. since my files are
larger than 33k, it seemed had to use this technique:
http://support.microsoft.com/default.aspx?scid=kb;en-us;322796
|
by: skunapareddy |
last post by:
I am needing to read a blob from database and pass it to another java program. I researched internet and found a program that reads a file on the client pc and gives bytes, but when I modified the code to read a blob from DB I am not having any luck, I am running this java programs using JDEVELOPER. Can anyone please give me some help?
The code is as follows:
...
private static byte getBytesFromBlob(Blob blob) throws Exception {
...
|
by: wizard |
last post by:
Here is a piece of code below for writing and reading blobs in SQLITE
database.
I ' ve a problem to read from blob struct called 'Points'
Any help would be appreciated
Reagards
Greg
#include <stdlib.h>
#include <stdio.h>
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |