473,399 Members | 3,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

>4000 characters in a TextBox

I'm having the same problem. Basically, what I need to
know is - Can I move more than 4000 characters from a
TextBox in a Web Form to a string? If so, some code that
illustrates how to do this would be appreciated.

-----Original Message-----
Hi,

I'm trying to send >4000 text data from a TextBox to a
clob column of an Oracle table.

code:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Threading;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;

namespace clobdata
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected
System.Web.UI.WebControls.TextBox TextBox1;
protected
System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.Button
Button2;
protected System.Web.UI.WebControls.Label
Label1;
protected System.Web.UI.WebControls.Label
Label2;

protected System.Web.UI.WebControls.Button
Button1;

private void Page_Load(object sender,
System.EventArgs e)
{

}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required
by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support -
do not modify
/// the contents of this method with the
code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new
System.EventHandler(this.Button1_Click);
this.Button2.Click += new
System.EventHandler(this.Button2_Click);
this.Load += new
System.EventHandler(this.Page_Load);

}
#endregion

private void Button1_Click(object sender,
System.EventArgs e)
{
String s = TextBox1.Text;

OracleConnection con = Connect
("User Id=scott;Password=tiger;Data Source=Oracle");

StringBuilder blr;
OracleCommand cmd = new
OracleCommand("", con);

blr = new StringBuilder();
blr.Append("DROP TABLE clobtest");
cmd.CommandText = blr.ToString();
try
{
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
//Console.WriteLine
("Warning: {0}", ex.Message);
}

blr = new StringBuilder();
blr.Append("CREATE TABLE clobtest
(col1 NUMBER(4) PRIMARY KEY,");
blr.Append("clobcol CLOB, sound
BLOB)");
cmd.CommandText = blr.ToString();
try
{
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.WriteLine("Error:
{0}", ex.Message);
}

blr = new StringBuilder();
blr.Append("INSERT INTO clobtest
values(");
blr.Append("1,");
blr.Append("'" + s + "',");
blr.Append("'65667777')");
cmd.CommandText = blr.ToString();
try
{
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.WriteLine("Error:
{0}", ex.Message);
}

StringBuilder sql = new
StringBuilder();
sql.Append("create or replace
procedure Selectclobcol ( ");
sql.Append("clob_data OUT CLOB)
as ");
sql.Append("begin ");
sql.Append(" select clobcol into
clob_data from clobtest where col1 = 1; ");
sql.Append("end Selectclobcol;");
cmd.CommandText = sql.ToString();
try
{
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.WriteLine("Error:
{0}", ex.Message);
}

// Set the command
OracleCommand cmd2 = new
OracleCommand("", con);
cmd2.CommandText = "Selectclobcol";
cmd2.CommandType =
CommandType.StoredProcedure;

// Bind the OraLob Object
OracleParameter param =
cmd2.Parameters.Add("clobdata", OracleDbType.Clob);
param.Direction =
ParameterDirection.Output;

// Execute command
try
{
cmd2.ExecuteNonQuery();

string lob_data = (string)
((OracleClob)(cmd2.Parameters[0].Value)).Value;

}
catch (Exception ex)
{
Console.WriteLine
(ex.Message);
}
finally
{
// Dispose OracleCommand
object
cmd2.Dispose();

// Close and Dispose
OracleConnection object
con.Close();
con.Dispose();
}
}
public static OracleConnection Connect
(string connectStr)
{
OracleConnection con = new
OracleConnection(connectStr);
try
{
con.Open();
}
catch (Exception e)
{
Console.WriteLine("Error:
{0}", e.Message);
}
return con;
}

private void Button2_Click(object sender,
System.EventArgs e)
{
OracleConnection con = Connect
("User Id=scott;Password=tiger;Data Source=dell2");
OracleCommand cmd = new
OracleCommand("select clobcol from clobtest where col1 =
1");
//OracleCommand cmd = new
OracleCommand("select sound from clobtest where col1 = 1"); cmd.Connection = con;
cmd.CommandType = CommandType.Text;

OracleDataReader reader = null;
try
{
//cmd.ExecuteNonQuery();
// Create DataReader
reader = cmd.ExecuteReader
();

// Read the first row
while(reader.Read())
{
// Set the
OracleClob object to the CLOB selected
OracleClob clob =
reader.GetOracleClob(0);

//OracleBlob blob
= reader.GetOracleBlob(0);

String str3 =
clob.Value;
//String str4 =
blob.Value.Length.ToString();

//Label2.Text =
str4;
TextBox2.Text =
str3;
Label1.Text
= "Number of characters is " + str3.Length.ToString();
}

}
catch (Exception ex)
{
Console.WriteLine
("Exception:" + ex.Message);
}
finally
{
cmd.Dispose();
con.Close();
con.Dispose();
}
}
}
}
bebop
.

Nov 17 '05 #1
0 4076

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dave Pylatuk | last post by:
Hello all. I have a situation where several computers running a Powerbuilder application receive the above error message. This application is hitting an 8.1.7 oracle db and runs fine on...
2
by: Francesco Moi | last post by:
Hello. I designed a form to edit some DataBase's fields. But some of these fields contain '&lt;' and '&gt;' characters. And these characters are '<' and '>' in HTML. So if want to edit these...
5
by: Grahammer | last post by:
Sorry for the whining, but I'm getty VERY frustrated trying to do some very simple jobs with DotNet and finding out that they are just impossible or involve a LOT of work. - Print a RichTextBox...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
4
by: David Lozzi | last post by:
Howdy, I'm using a WYSIWYG editor called TinyMCE. When I edit some text and then save it back to my SQL server using a SQLCommand, all HTML characters are changed to HTML code, i.e. &gt;strong&lt;...
1
by: seeCoolGuy | last post by:
I've been using Access to import some data straight into a sql server database by simply importing the xml file. However lately some of the newer xml files will contain vaild data such as ...
3
by: Man-wai Chang | last post by:
A 2 columns x 10 rows matrix input form <ul> <li> <ul> <li>item name 1 <li><input type="textbox" name="input_col_1_row_1"> <li><input type="textbox" name="input_col_1_row_2"> </ul> <li>
1
by: jcgurango | last post by:
ok, I have 2 pages, one has a code on it, and the other has a textbox with a button....... I wanna make it so that when you press the button, whatever is on the textbox will be the value of the...
6
by: uicouic | last post by:
I have a textbox named "txtName" and a button (btnSave) on a webform. After I have typed the illegal characters into the textbox and click "Save", I would like the webform to check for those...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
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...
0
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...
0
Oralloy
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,...
0
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...
0
tracyyun
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...
0
isladogs
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...

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.