[FIXED] SqlDbType.NText size problem

Posts   
 
    
Fabrice
User
Posts: 180
Joined: 25-May-2004
# Posted on: 01-Jul-2004 10:32:33   

I use the modifications to the adapter to have paging support (found in 3rd party section). But I've a "ORMQueryExecutionException" when I use it :

SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: An exception was caught during the execution of a retrieval query: The size (1073741823) given to the column 'ENote' exceeds the maximum allowed for any data type (8000).. Check InnerException, QueryExecuted and Parameters of this exception to examine the cau
se of this exception.

The field "ENote" is a ntext(16) field. When I take a look in DataBaseSpecific/PersistenceInfoFactory.cs for this entity I see :

toReturn.AddFieldPersistenceInfo("ENote", new FieldPersistenceInfo("HRANew", "dbo", "EMPLOYEE", "E_NOTE", true, (int)SqlDbType.NText, 1073741823, 0, 0, false, ""));

so .. I see '1073741823' instead of '16' It's a bug or I made an error ? How to retrieve the real SQL length (16) ? Info : ORMSupportClasses version 1.0.2003.3

Fabrice
User
Posts: 180
Joined: 25-May-2004
# Posted on: 01-Jul-2004 10:40:59   

I've make a work around to be able to use paging: with text and ntext fields, the CreateColumn methods don't use the persistenceInfo.SourceColumnMaxLength. But I don't know if I'll not have the same problem elsewhere.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 01-Jul-2004 14:01:40   

Fabrice wrote:

I use the modifications to the adapter to have paging support (found in 3rd party section). But I've a "ORMQueryExecutionException" when I use it :

SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: An exception was caught during the execution of a retrieval query: The size (1073741823) given to the column 'ENote' exceeds the maximum allowed for any data type (8000).. Check InnerException, QueryExecuted and Parameters of this exception to examine the cau
se of this exception.

The field "ENote" is a ntext(16) field. When I take a look in DataBaseSpecific/PersistenceInfoFactory.cs for this entity I see :

toReturn.AddFieldPersistenceInfo("ENote", new FieldPersistenceInfo("HRANew", "dbo", "EMPLOYEE", "E_NOTE", true, (int)SqlDbType.NText, 1073741823, 0, 0, false, ""));

so .. I see '1073741823' instead of '16' It's a bug or I made an error ? How to retrieve the real SQL length (16) ? Info : ORMSupportClasses version 1.0.2003.3

The size is set to 1GB, which is the default for NText. 16 is not the real length of the field, it's 1GB. All entity code generated with text or ntext uses the large length and parameters for these fields are set to 1GB in size as well (normal text fields to 2GB). Are you using SqlServer 7?

Frans Bouma | Lead developer LLBLGen Pro
Fabrice
User
Posts: 180
Joined: 25-May-2004
# Posted on: 02-Jul-2004 11:56:25   

No it's SQL 2000 I know the real length is 1 Gb, but when you have to create a column using persistence information SourceColumnMaxLength property, if you give "ntext(1073741823)" to SQL you'll get an error. You have to use "ntext(16)" or "ntext". There is a "persistenceInfo.SourceColumnMaxLength" which contains real length for c# code. Maybe you should add a "persistenceInfo.DBSourceColumnMaxLength" which contain the length for the database server. In my example it will change only for ntext and text dbtype, but maybe on oracle there is also the problem.

The problem only occur when we try to give the fields length to sql (for example when creating temp table with paging hack)

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 02-Jul-2004 19:06:32   

Fabrice wrote:

No it's SQL 2000 I know the real length is 1 Gb, but when you have to create a column using persistence information SourceColumnMaxLength property, if you give "ntext(1073741823)" to SQL you'll get an error. You have to use "ntext(16)" or "ntext". There is a "persistenceInfo.SourceColumnMaxLength" which contains real length for c# code. Maybe you should add a "persistenceInfo.DBSourceColumnMaxLength" which contain the length for the database server. In my example it will change only for ntext and text dbtype, but maybe on oracle there is also the problem.

The problem only occur when we try to give the fields length to sql (for example when creating temp table with paging hack)

Ah, ok, I already wondered why it would turn up as a problem. Ok, so the paging templates need a fix for this. I'll check it out.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 03-Jul-2004 12:44:39   

I've uploaded an updated 3rd party template archive which should fix this issue.

Frans Bouma | Lead developer LLBLGen Pro