0

I am using Report Viewer for my ASP.net application's reporting purpose. The problem is, when I have data less than 50 characters in my table(DB is SQL Server) report works properly but when data goes beyond 50 characters it gives error as,

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. 

I cant't resolve the issue, PLease Help thanks in advance

Alex
  • 4,821
  • 16
  • 65
  • 106
Nils
  • 171
  • 2
  • 2
  • 11
  • This problem is usually caused by either null values being returned for columns not set to AllowDBNull, or duplicate rows being returned with the same primary key.how you know that it's a textbox 50 character limit problem.use `try catch` exception block for exect error. – Rahul Jun 05 '13 at 09:42
  • Thanks @Rahul - when I put data longer than 50 characters it gives me such error, else it works good – Nils Jun 05 '13 at 09:43
  • @rahul I have checked for null / duplicate values / key violation. It's ok but only issue is with string length – Nils Jun 05 '13 at 09:44
  • are you using `try catch` block or not,if no then use it,you will get exact error. – Rahul Jun 05 '13 at 09:47
  • @Rahul 's comment originally comes from the answer to [Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints](http://stackoverflow.com/a/7029713/456814). –  Aug 15 '14 at 05:01

2 Answers2

0

If you are using a TableAdapter:

Open Dataset and select the TableAdapter.

Select DataColumn giving this error and in the properties panel change the option MaxLength to the size you need

Leonardo
  • 41
  • 5
0

you can edit your dataset file with extension *.xsd with notepad and then change maximum value for your column name/field name

example :

          <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>

i change maxlength from 50 to 1000

hope this will help you

Thank You

Harry.wong
  • 12
  • 3