Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I need to save an image in oracle using oledb. My code is below...
C#
string query = "insert into signtable(Cname,Csign) values('" + saveLocation + "'," + " :BlobParameter )";
OleDbParameter blobParameter = new OleDbParameter();
blobParameter.OleDbType = OleDbType.Binary;
blobParameter.ParameterName = "BlobParameter";
blobParameter.Value = blob;    //here blob contains byte[] of image's data
cmd = new OleDbCommand(query, con);
cmd.Parameters.Add(blobParameter);
cmd.ExecuteNonQuery(); //here error

it throws an error as
ORA-01008: not all variables bound

Please tell me where i made mistake...I am new to oracle... Please....Help me out from this :(

I had made a big search...but no luck :(
Posted
Updated 20-Jun-11 0:44am
v2
Comments
Sandeep Mewara 20-Jun-11 6:45am    
What is 'Csign' datatype and range in DB?
J.Karthick 20-Jun-11 8:21am    
Csign is "BLOB" field...i didn't specify range for it...

1 solution

Does this[^] help?

I'm also curious why use a parameter for the blob field, but not for the location.

Do this:
C#
string query = "insert into signtable(Cname,Csign) values(:saveLocation, :BlobParameter)"


and add the savelocation as parameter as well.


also it could be that
blobParameter.ParameterName = "BlobParameter";
should be
blobParameter.ParameterName = ":BlobParameter";
 
Share this answer
 
Comments
J.Karthick 21-Jun-11 6:57am    
ya...thanks for your reply.
i used
query = "insert into signtable(Cname,Csign) values('" + saveLocation + "',?)";
cmd = new OleDbCommand(query, con);
cmd.Parameters.Add(new OleDbParameter("Csign",OleDbType.VarBinary));
cmd.Parameters["Csign"].Value = blob;
cmd.ExecuteNonQuery();

It throws
ORA-01460: unimplemented or unreasonable conversion requested

No end for this bug huh?? :(
J.Karthick 21-Jun-11 6:58am    
Even i changed OledbType.LongVarBinary and some more...No luck
V. 21-Jun-11 7:02am    
I think that your first attempt (original question) is closer to a solution. change the name of the parameter from "BlobParameter" to ":BlobParameter"
ugandhar kudipudi 3-Aug-12 1:36am    
Hi, i'm new to vb.net.. if u solved the above solution plz post the solved code.

Yugandhar.
sandip_1365 22-Aug-12 2:43am    
my code is :
Public Class Screenshot

Public Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal dwRop As Integer) As Integer
Public Declare Function GetWindowDC Lib "user32" Alias "GetWindowDC" (ByVal hwnd As Integer) As Integer
Public Declare Function ReleaseDC Lib "user32" Alias "ReleaseDC" (ByVal hwnd As Integer, ByVal hdc As Integer) As Integer
Public Const SRCCOPY As Integer = &HCC0020
Public Shared Sub CreateBitmap()
Dim gDest As Graphics
Dim hdcDest As IntPtr
Dim hdcSrc As Integer
Dim hWnd As Integer '= Control.Handle.ToInt32
Dim bmp As Bitmap
'Dim insert_query As String
Dim strHostName As String = Net.Dns.GetHostName()
'Dim strIpAddress As String = System.Net.Dns.GetHostByAddress(strHostName).AddressList(0).ToString()

'Dim strIPAddress As String = System.Net.Dns.GetHostByName(strHostName).AddressList(0).ToString()
Dim strIPAddress As String = Net.Dns.GetHostByName(strHostName).AddressList(0).ToString()

hWnd = Process.GetCurrentProcess.MainWindowHandle.ToInt32
bmp = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb)
gDest = Graphics.FromImage(bmp)
hdcSrc = GetWindowDC(hWnd)
hdcDest = gDest.GetHdc

BitBlt(hdcDest.ToInt32, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, hdcSrc, 0, 0, SRCCOPY)

gDest.ReleaseHdc(hdcDest)
ReleaseDC(hWnd, hdcSrc)
'bmp.Save("C:\BITMAP" & DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") & ".png")
bmp.Save("C:\BITMAP.jpg") ', System.Drawing.Imaging.ImageFormat.Bmp)
Dim inflenm As String
inflenm = "C:\BITMAP.jpg"
Dim connstr As String

If strIPAddress.Substring(8, 1) = 2 Then
connstr = "conn"
Else
connstr = "conn"
End If

Dim conn As New System.Data.OleDb.OleDbConnection(connstr)
Dim instream As New FileStream(inflenm, FileMode.Open, FileAccess.Read)
Dim infileln As Long = instream.Length
Console.WriteLine("file lenght is {0}", infileln)
Dim indata As Byte() = New Byte(infileln - 1) {}
Console.WriteLine("read {0} bytes from file..", instream.Read(indata, 0, CInt(infileln)))
instream.Close()
conn.Open()
Dim PDATE As String
Dim PTIME As String
PDATE = Now.Day & "/" & Now.Month & "/" & Now.Year
PTIME = Now.Hour & "." & Now.Minute

'Dim strinsert As String = "insert into img (abc,COMPUTERNM,IPADD,CURDATE) values(:lobval,'" + strHostName + "','" + strIPAddress + "','" + Convert.ToDateTime(System.DateTime.Now.TimeOfDay.ToString()) + "')" '---,'" + System.DateTime.Now.Date + "'
Dim strinsert As String = "insert into pc_snap (img,COMPUTERNM,IPADD,CURDATE,CURTIME) values(:lobval,'" + UCase(strHostName) + "','" + strIPAddress + "','" + PDATE + "','" + PTIME & "')" '---,'" + System.DateTime.Now.Date + "'
Dim lrval As New System.Data.OleDb.OleDbParameter(":lobval", OleDbType.LongVarBinary)
lrval.OleDbType = OleDbType.LongVarBinary
lrval.ParameterName = "lobval"
lrval.Direction = ParameterDirection.Input
lrval.Value = indata
Dim CMD As New System.Data.OleDb.OleDbCommand(strinsert, conn)
CMD.Parameters.Add(lrval)
CMD.ExecuteNonQuery()
conn.Close()
End Sub
End Class
:----
it give error
searching big but not give any result
Please Help Me......

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900