No mapping exists from DbType AnsiString to a known SqlDbType

Posts   
 
    
David H
User
Posts: 100
Joined: 31-Dec-2004
# Posted on: 03-Sep-2008 04:20:57   

I am getting the error listed below when using the following code under SQL CE. This works under SQL Express 2008:

Dim entities As New CollectionClasses.MeterLocatorCollection
Dim filter As IPredicateExpression = New PredicateExpression()
Dim filterElement As IPredicate = Not (HelperClasses.MeterLocatorFields.MeterNumber = "")
filter.Add(filterElement)
entities.GetMulti(filter)

I also tried:

Dim filterElement As IPredicate = (HelperClasses.MeterLocatorFields.MeterNumber <> "")

Thanks

David

System.ArgumentException occurred Message="No mapping exists from DbType AnsiString to a known SqlDbType." Source="System.Data.SqlServerCe" StackTrace: at System.Data.SqlServerCe.SqlCeType.FromDbType(DbType type) at System.Data.SqlServerCe.SqlCeParameter.set_DbType(DbType value) at SD.LLBLGen.Pro.DQE.SqlServer.SqlServerSpecificCreator.CreateFilledParameter(String parameterName, SqlDbType dbTypeToUse, Int32 size, ParameterDirection direction, Boolean isNullable, Byte precision, Byte scale, Object value) at SD.LLBLGen.Pro.DQE.SqlServer.SqlServerCeSpecificCreator.CreateParameter(IEntityFieldCore field, IFieldPersistenceInfo persistenceInfo, ParameterDirection direction, Object valueToSet) at SD.LLBLGen.Pro.ORMSupportClasses.FieldCompareValuePredicate.ToQueryText(Int32& uniqueMarker, Boolean inHavingClause) at SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText(Int32& uniqueMarker, Boolean inHavingClause) at SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText(Int32& uniqueMarker, Boolean inHavingClause) at SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText(Int32& uniqueMarker) at SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Boolean relationsSpecified, Boolean sortClausesSpecified) at SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause) at SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.CreatePagingSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize) at SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize) at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformGetMultiAction(ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPredicate selectFilter, IRelationCollection relations, IPrefetchPath prefetchPathToUse, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize) at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.GetMulti(ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IEntityFactory entityFactoryToUse, IPredicate selectFilter, IRelationCollection relations, IPrefetchPath prefetchPathToUse, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize) at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase1.GetMulti(IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relations, IPrefetchPath prefetchPathToUse, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize) at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase1.GetMulti(IPredicate selectFilter) at isr.Provers.Library.LocalMeterLocator.FetchRecordset() in C:\My\Projects\PGE\Provers.7.0\Solution\Libraries\Provers\Data\LocalMeterLocator.vb:line 288 InnerException:

David H
User
Posts: 100
Joined: 31-Dec-2004
# Posted on: 03-Sep-2008 05:43:03   

I have a bit more info on the previous post.

  1. I am able to fetch records from another table where the PK is nchar type.
  2. I am getting the same error on fetching using PK (the field happens to be a PK);
  3. The field causing the issue is declared nvarchar in the CE database.
  4. In the SQL Express database (which was used to create the CE database) the same field is varchar.
  5. A previous edition of the program worked with nvarchar and LLBLGEN 2.5 and SQLX 2005.

Thanks

David

David H
User
Posts: 100
Joined: 31-Dec-2004
# Posted on: 03-Sep-2008 06:39:23   

Hi,

Please hold off on looking into this matter as I might have an answer to this problem, which I'll be testing tomorrow.

David

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 03-Sep-2008 11:22:12   

Waiting for your feedback.

David H
User
Posts: 100
Joined: 31-Dec-2004
# Posted on: 16-Sep-2008 05:36:40   

The problem was due to a mismatch in the data types between the SQL Express and CE versions of the database.

When converting to CE, VARCHAR types changed to NVARCHAR.

Solution: Use NVARCHAR in the SQL database that is used to build the project.