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

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);
                }
            }
        }

转载于:https://www.cnblogs.com/liushenghuan/p/5740305.html

你可能感兴趣的:(C#实现Oracle数据库插入clob字段类型数据)