[Mono-dev] Maybe a System.Data.OracleClient.dll bug
Daniel Morgan
monodanmorg at yahoo.com
Thu Sep 21 00:07:57 EDT 2006
Does your insert statement work in sqlplus?
Also, does your test case work on microsoft .net?
Have you used this:
OracleParameter parm = new OracleParameter(":name",
OracleType.NVarChar);
Which has OracleType of NVarChar instead of VarChar.
And in your table you created, have it created with
NVARCHAR2 instead of VARCHAR2
create table test(name nvarchar2(1000));
--- David <jiangchengyao at gmail.com> wrote:
> I use System.Data.OracleClient to connect and
> operate oracle database;
> But I find a problem when inserting into oracle
> database with chinese
> character;
> Here is a simple exapmle:
>
> using System;
> using System.Data;
> using System.Data.OracleClient;
>
> namespace Test{
> class MainEntry{
> public static void Main(string[] args){
> String connString = "server=video;User
> Id=mono;password=jcyjcy";
> String insertSql = "INSERT INTO
> test(name) values (:name)";
> OracleConnection conn = new
> OracleConnection(connString);
> try{
> conn.Open();
> OracleCommand command = new
> OracleCommand();
> command.Connection = conn;
> command.CommandText = insertSql;
> command.CommandType =
> CommandType.Text;
> OracleParameter parm = new
> OracleParameter(":name",
> OracleType.VarChar);
> // insert a Chinese stiing into
> oracle database(the string's
> length is 4)
> parm.Value = "²âÊÔ²åÈë";
> command.Parameters.Add(parm);
> command.ExecuteNonQuery();
> }
> catch(Exception ex){
>
> Console.WriteLine(String.Format("Error is:
> {0}",ex.Message
> ));
> }
> finally{
> conn.Close();
> }
> }
> }
> }
>
>
> and the create table is :
> create table test(name varchar(1000));
>
> in sqlplus :
> select * from test;
> You will see the result is not we expected,not all
> the character insert into
> the database.
>
> Can't anybody tell me how to resolve this problem?
> > _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
>
http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Mono-devel-list
mailing list