【问题标题】:Not able to insert long text in database无法在数据库中插入长文本
【发布时间】:2015-06-11 23:47:22
【问题描述】:

我通过 jquery 在 asp.net 应用程序中的应用程序中有ckeditor

local 运行良好。它在数据库中插入数据,没关系 无论文本的长度是多少。但是当我在现场插入数据后 将构建放在服务器上。

它不保存数据,当我减少它的长度时,它正在保存数据。我正在使用 WCF 服务插入此文本。

请在这方面提供帮助。

期待听到同样的消息。

【问题讨论】:

  • 您需要将服务器上相应列的数据类型设置为nvarchar(max)
  • 错误出现在哪里?例如,这可能是因为列没有合适的类型/宽度,但由于您提到 jQuery,可能是因为您将其作为查询字符串参数传输,并且您的 url 太长(并且被拒绝服务器)
  • 也许您需要增加 WCF 中消息的最大大小:stackoverflow.com/questions/884235/…

标签: c# jquery asp.net wcf fckeditor


【解决方案1】:

Oracle DB 接受 4000 个字符作为输入字符串(不是数据类型)的最大长度。 即,您最多应发送 4000 个字符作为值。 解决方案: 如果您使用的是 ASP.NET,请在将列类型更改为 CLOB 后尝试使用此功能,使其大小达到 4GB:

 Public Shared Function AssignStringToCLOB(ByVal targetString As String, ByVal myConnection As OracleConnection) As OracleLob
    Dim _tempCommand As New OracleCommand()
    _tempCommand.Connection = myConnection
    _tempCommand.Transaction = _tempCommand.Connection.BeginTransaction()
    _tempCommand.CommandText = "DECLARE A " + OracleType.Clob.ToString() + "; " + "BEGIN " + "DBMS_LOB.CREATETEMPORARY(A, FALSE); " + ":LOC := A; " + "END;"
    Dim p As OracleParameter = _tempCommand.Parameters.Add("LOC", OracleType.Clob)
    p.Direction = ParameterDirection.Output

    _tempCommand.ExecuteNonQuery()

    Dim _tempCLOB As OracleLob = CType(p.Value, OracleLob)
    If targetString <> String.Empty Then
        Dim _bytesArray As Byte() = Text.Encoding.Unicode.GetBytes(targetString)
        _tempCLOB.BeginBatch(OracleLobOpenMode.ReadWrite)
        _tempCLOB.Write(_bytesArray, 0, _bytesArray.Length)
        _tempCLOB.EndBatch()
    End If

    _tempCommand.Transaction.Commit()
    Return _tempCLOB
End Function

并在打开与 Oracle DB 的连接后调用它来为您的参数设置一个值,这应该可以正常工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-16
    相关资源
    最近更新 更多