Ask a Question related to ASP.NET General, Design and Development.
-
phil #1
>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.
1");>-----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 => 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
>
>
>.
>phil Guest
-
Installing eye candy 4000
i just purchased Eye candy 400 full edition, how do i set it up in fireworks? i saw that in the eye candy 400 effects section, choosing marble, then... -
eye candy 4000 serial number
Can anyone share with me a working serial number for eye candy 4000 photoshop plug-in? -
Limit to 150 characters in multi-line textbox
Can you limit the number of characters in a multi-line textbox? My tests in indicate that the MaxLength property causes client side limits only on... -
How to configure Inforprint 4000 under AIX
Hi, We have IBM infoprint 4000 Model IS1 AFP printer with TCP/IP connection, our objective is to print through AIX non afp files, we have been... -
Logitech QuickCam 4000 Pro
I have a Logitech QuickCam 4000 Pro which I cannot get working. Has anyone had experience with this? I have configured and built the kernel and... -
Steve C. Orr, MCSD #2
Re: >4000 characters in a TextBox
I think you're out of luck.
Your next best option is perhaps to create multiple textboxes, with the text
split between them all. Each textbox should have no more than 4000
characters.
On the server, combine them and insert into your database table.
--
I hope this helps,
Steve C. Orr, MCSD
[url]http://Steve.Orr.net[/url]
"bebop" <cwbp15@yahoo.com> wrote in message
news:9b9901c34643$94280630$a401280a@phx.gbl...> 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
>
>
Steve C. Orr, MCSD Guest



Reply With Quote

