【问题标题】:Text Box Not Accepting More Than 50 Characters?文本框不接受超过 50 个字符?
【发布时间】:2016-04-29 18:11:31
【问题描述】:

我将 Report Viewer 用于我的 ASP.net 应用程序的报告目的。 问题是,当我的表中的数据少于 50 个字符时(DB 是 SQL Server)报告可以正常工作,但是当数据超过 50 个字符时,它会给出错误,

An error has occurred during report processing.
Cannot create a connection to data source 'DataSet1'.
Exception has been thrown by the target of an invocation.
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints. 

我无法解决问题,请帮助 提前致谢

【问题讨论】:

  • 这个问题通常是由于没有设置为 AllowDBNull 的列返回空值,或者使用相同的主键返回重复的行。你怎么知道这是一个文本框 50 个字符的限制问题。使用try catch 执行错误的异常块。
  • 感谢@Rahul - 当我输入超过 50 个字符的数据时,它会给我这样的错误,否则效果很好
  • @rahul 我检查了空值/重复值/键违规。没关系,但唯一的问题是字符串长度
  • 你是否使用try catch block,如果没有使用它,你会得到确切的错误。

标签: asp.net .net reportviewer rdlc


【解决方案1】:

您可以使用记事本编辑扩展名为 *.xsd 的数据集文件 然后更改列名/字段名的最大值

例子:

          <xs:element name="InvDesc" msprop:Generator_ColumnVarNameInTable="columnInvDesc" msprop:Generator_ColumnPropNameInRow="InvDesc" msprop:Generator_ColumnPropNameInTable="InvDescColumn" msprop:Generator_UserColumnName="InvDesc">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:maxLength value="1000" />
              </xs:restriction>
            </xs:simpleType>
          </xs:element>

我将 maxlength 从 50 更改为 1000

希望对你有帮助

谢谢

【讨论】:

    【解决方案2】:

    如果您使用的是 TableAdapter:

    打开数据集并选择 TableAdapter。

    选择出现此错误的 DataColumn,然后在属性面板中将选项 MaxLength 更改为您需要的大小

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-22
      • 2015-01-04
      • 1970-01-01
      • 2015-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多