码迷,mamicode.com
首页 > 数据库 > 详细

C#实现Oracle数据库插入clob字段类型数据

时间:2016-08-05 11:51:39      阅读:270      评论:0      收藏:0      [点我收藏+]

标签:

public static void InsertWithLob(OracleConnection conn)
        {
            if (conn!= null && conn.State == ConnectionState.Open)
            {
                try
                {
                    string sqlText = "insert into tb_nclob(id,name,text) values(1,‘test‘,:text)";
                    using (OracleCommand cmd = new OracleCommand(sqlText, conn))
                    {
                        OracleParameter oracleParameter = new OracleParameter("text", OracleType.Clob);
                        oracleParameter.Value = "this is my test";
                        cmd.Parameters.Add(oracleParameter);
                        int rows = cmd.ExecuteNonQuery();

         cmd.Parameters.Clear();
                        return rows;
                    }
                }
                catch (OracleException ex)
                {
                    throw new Exception(ex.Message);
                }
            }
        }

C#实现Oracle数据库插入clob字段类型数据

标签:

原文地址:http://www.cnblogs.com/liushenghuan/p/5740305.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!