[Mono-dev] ORA-01480 error
Leszek Ciesielski
skolima at gmail.com
Fri Dec 15 09:43:12 EST 2006
On 12/15/06, David <jiangchengyao at gmail.com> wrote:
> When I use OracleParameter to insert Chinese string into oracle database,it
> cast error like followings:
> ORA-01480: trailing null missing from STR bind value
>
> It happens only when I insert chinese string to database, no error when
> inserting english string.
>
> But when I use direct insert sql string,no error happens for both chinese
> string and english string.
>
> Error sample:
>
> Test_Error.aspx
> <%@ Page Language="C#" %>
> <%@ Assembly Name=" System.Data.OracleClient" %>
> <%@ Import Namespace="System.Data" %>
> <%@ Import Namespace="System.Data.OracleClient" %>
>
> <body>
> <form runat="server">
> <asp:TextBox runat="server" id="content"/>
> <input type="Button" Value="Click" runat="server" id="button"
> OnServerClick="OnClick"/>
> </form>
> </body>
>
> <script runat="server">
> public void OnClick(object sender,EventArgs e){
> if(content.Text != String.Empty || content != null){
> Response.Write(content.Text);
> String connString = "Server=//127.0.0.1:1521/david
> ;User Id=mono;Password=jcyjcy";
> OracleConnection conn = new OracleConnection(connString);
> try{
> conn.Open();
> Response.Write("OpenSucess");
> OracleCommand command = new OracleCommand();
> command.Connection = conn;
> command.CommandType = CommandType.Text;
> // here I use OracleParameter
> String insertText = "insert into test values (:name)";
> command.CommandText = insertText;
> command.Parameters.Add (":name",OracleType.NVarChar ,1000);
> command.Parameters[0].Value = content.Text;
> Response.Write(command.Parameters [0].Value);
> int affectedRows = command.ExecuteNonQuery();
> if(affectedRows == 1)
> Response.Write("insert sucess");
> }
> catch(Exception ex){
> Response.Write(ex.Message);
> }
> finally{
> conn.Close();
> }
> }
> }
> </script>
>
> No error sample:
>
> No_error.aspx
> <%@ Page Language="C#" %>
> <%@ Assembly Name="System.Data.OracleClient " %>
> <%@ Import Namespace=" System.Data" %>
> <%@ Import Namespace="System.Data.OracleClient" %>
>
> <body>
> <form runat="server">
> <asp:TextBox runat="server" id="content"/>
> <input type="Button" Value="Click" runat="server" id="button"
> OnServerClick="OnClick"/>
> </form>
> </body>
>
> <script runat="server">
> public void OnClick(object sender,EventArgs e){
> if(content.Text != String.Empty || content != null){
> Response.Write(content.Text);
> String connString = "Server=//127.0.0.1:1521/david ;User
> Id=mono;Password=jcyjcy";
> OracleConnection conn = new OracleConnection(connString);
> try{
> conn.Open();
> Response.Write("OpenSucess");
> OracleCommand command = new OracleCommand();
> command.Connection = conn;
> command.CommandType = CommandType.Text;
> // not use OracleParameter, direct use sql
> String insertText = String.Format("insert into test
> values('{0}')",content.Text );
> command.CommandText = insertText;
> int affectedRows = command.ExecuteNonQuery();
> if(affectedRows == 1)
> Response.Write("insert sucess");
> }
> catch(Exception ex){
> Response.Write(ex.Message );
> }
> finally{
> conn.Close();
> }
> }
> }
> </script>
>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
>
http://bugzilla.ximian.com/show_bug.cgi?id=80030
And there is a regression test for this in repository. Please either
help (send a patch) or don't report the same bug over and over. I am
aware of it, but I do not know how to fix this.
--
MS-DOS user since 5.0
Windows user since 3.11
Linux user since kernel 2.4
Novell Netware user since 2.2
WARCRAFT user since 1.0
More information about the Mono-devel-list
mailing list