If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Insert Blob data to DB2 by .net

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-13-11, 04:03
nmcuong nmcuong is offline
Registered User
 
Join Date: Jul 2011
Posts: 10
Question Insert Blob data to DB2 by .net

Hello every body !

How can I insert blob data to DB2 by .Net?


DB2Connection d2Conn = new DB2Connection();
d2Conn.ConnectionString = "Server=192.168.1.107:50000;Database=dbtest;UID=db 2admin;PWD=db2admin";
d2Conn.Open();

DB2Command d2Command = new DB2Command();
d2Command.Connection = d2Conn;
d2Command.CommandType = CommandType.StoredProcedure;
d2Command.CommandText = "PROFILE_ADD";

List<DB2Parameter> list = new List<DB2Parameter>();
DB2Parameter p1 = new DB2Parameter();
p1.ParameterName = "v_ID";
p1.Value = "0000000001";
p1.DB2Type = DB2Type.Graphic;
p1.Size = 10;
list.Add(p1);

DB2Parameter obj2 = new DB2Parameter();
obj2 .DB2Type = DB2Type.Blob;
obj2 .ParameterName = "v_FileContent";

FileStream fs = new FileStream("C:\Text.txt", FileMode.OpenOrCreate, FileAccess.Read);
byte[] MyData = new byte[fs.Length];
fs.Read(MyData, 0, System.Convert.ToInt32(fs.Length));

fs.Close();

obj2.Value = MyData;

d2Command.Parameters.AddRange(list.ToArray());
d2Command.ExecuteNonQuery();

When run that source code, the error "ERROR [57011] [IBM][DB2/NT] SQL0930N There is not enough storage available to process the statement. SQLSTATE=57011" has been throw.

How can I fix this error? Please help me!!!!!!
Reply With Quote
  #2 (permalink)  
Old 07-13-11, 04:51
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
in the sample directory there is a sample with some remarks - maybe this will help
** SOURCE FILE NAME: DtLob.cs
**
** SAMPLE: How to use the LOB data type with the DB2 .Net Data Provider
**
** Before running this sample, ensure that you set the database
** manager configuration parameter UDF Shared Memory Set Size
** (udf_mem_sz) to at least two pages more than the larger
** of the input arguments or the resulting CLOB being retrieved.
**

best regards, guy
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #3 (permalink)  
Old 07-13-11, 23:32
nmcuong nmcuong is offline
Registered User
 
Join Date: Jul 2011
Posts: 10
Quote:
Originally Posted by przytula_guy View Post
in the sample directory there is a sample with some remarks - maybe this will help
** SOURCE FILE NAME: DtLob.cs
**
** SAMPLE: How to use the LOB data type with the DB2 .Net Data Provider
**
** Before running this sample, ensure that you set the database
** manager configuration parameter UDF Shared Memory Set Size
** (udf_mem_sz) to at least two pages more than the larger
** of the input arguments or the resulting CLOB being retrieved.
**

best regards, guy
Thanks !!!!!!!!!!!!!!!!!!!!!!!!!!!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On