Invalid object name issue

Posts   
 
    
KevinIson
User
Posts: 3
Joined: 11-Nov-2010
# Posted on: 11-Nov-2010 13:30:31   

Im using LLBL Gen Pro version 3 against a SQL Server 2008 R2 database. When using the generated code I get an error for the following code


Public Class CRBTApp

    Public Sub New()
        Dim sConn As String = System.Configuration.ConfigurationManager.AppSettings("ConnString").ToString()
        Repository.DaoClasses.CommonDaoBase.ActualConnectionString = sConn
    End Sub

    Public Sub Test()
        Dim colSubjects As New CollectionClasses.SubjectCollection()
        Dim filter As New PredicateExpression()

        Try
            filter.Add(SubjectFields.HostIdent > 100 And SubjectFields.HostIdent < 500)

            colSubjects.GetMulti(filter)
            colSubjects.Sort(SubjectFieldIndex.HostIdent, System.ComponentModel.ListSortDirection.Ascending)

            For Each entSubJect As SubjectEntity In colSubjects
                Debug.Print(entSubJect.SubjectId.ToString())
            Next
        Catch oex As ORMQueryExecutionException
            MessageBox.Show(oex.Message & vbCrLf & oex.InnerException.Message & vbCrLf & oex.StackTrace)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

    End Sub

End Class

The error message:

An exception was caught during the execution of a retrieval query: Invalid object name 'Repository.dbo.Subject'.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.

The stacktrace:

at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Query\RetrievalQuery.cs:line 132 at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.ExecuteMultiRowRetrievalQuery(IRetrievalQuery queryToExecute, ITransaction containingTransaction, IEntityCollection collectionToFill, Boolean allowDuplicates, IEntityFields fieldsUsedForQuery, IFieldPersistenceInfo[] fieldPersistenceInfos) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\SelfServicingSpecific\DaoBase.cs:line 1500 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) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\SelfServicingSpecific\DaoBase.cs:line 984 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) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\SelfServicingSpecific\DaoBase.cs:line 802 at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase1.GetMulti(IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relations, IPrefetchPath prefetchPathToUse, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\SelfServicingSpecific\EntityCollectionBase.cs:line 777 at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase1.GetMulti(IPredicate selectFilter) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\SelfServicingSpecific\EntityCollectionBase.cs:line 639 at BioTrustExport.CRBTApp.Test() in C:\Development\VS2010\GUI\BioTrustExport\BioTrustExport\Classes\CRBTApp.vb:line 29

The generated code I was given so that I could create an application against it. It is in use in a couple of other applications so I am thinking I am missing something somewhere but I have not been able to identify it in the docs....

What am I missing ?

Thanks

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 11-Nov-2010 20:39:41   

It sounds like your database is missing a table called "Subject". Could this be the case ?

Matt

KevinIson
User
Posts: 3
Joined: 11-Nov-2010
# Posted on: 11-Nov-2010 20:48:32   

MTrinder wrote:

It sounds like your database is missing a table called "Subject". Could this be the case ?

Matt

no ... actually the name of the database is wrong... turns out I had to make an adjustment in my app.config...


...
    <section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueSectionHandler"/>
  </configSections>

  <sqlServerCatalogNameOverwrites>
    <add key="Repository" value=""/>
  </sqlServerCatalogNameOverwrites>

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 11-Nov-2010 20:52:47   

That was going to be my next suggestion simple_smile

Happy to hear you are sorted - let us know if you have any further issues.

Matt