Catalog Names

Posts   
 
    
ElQueso avatar
ElQueso
User
Posts: 27
Joined: 08-Oct-2005
# Posted on: 21-Jul-2006 05:07:44   

I ran into a situation today that was a first. I'm using 1.0.2005.1, adapter scenario, SQL Server 2000, ASP.NET app.

I thought I might bring this up here, and since the behavior seems to be intended; I'm asking "why?" more than anything.

The problem occurred when I brought a client's database down to my development server to test some issues related to their data. When I attached their db to my server, I gave it a different name so I didn't need to detach my development db.

Much to my surprise, when I ran my app, I got the data from my development server instead of the client data.

I took me a little bit to figure out that this was due to the fact that the catalog name is always defaulted to the catalog the project was created with.

Now, I've searched through the threads and read the manual more carefully on this issue and I have figured out how to deal with this. The funny thing is that my app connects to as many as 5 different databases to gather its data, and I have a GenPro project for each catalog, and of course, because those catalog names stay the same from development to production, I've never had a problem (funny because GenPro handles that complexity quite nicely and efficiently using the different connection string entries).

I was just wondering why the default catalog name, instead of parsing it from the connection string? the entries I have to put in the config file will work (though it's a pain wink ), but it seems a little odd to have to do that instead of GenPro using the catalog defined in the connection string at runtime.

BTW - just wanted you to know that I do enjoy working with GenPro - this isn't a complaint thread, just trying to understand what seems to be somewhat of an anomaly.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 21-Jul-2006 05:37:46   

That's because you may add entities from more than one catalog in the same llblgen project. So to define which entity belongs to which catalog, this had to be maintained in code. The connection string can't provide this kind of detail.

Posts: 13
Joined: 15-Jan-2006
# Posted on: 21-Jul-2006 16:53:17   

Is there some sort of workaround for this? We have a system that has several databases that are running the same schema. Is there a way to set the catalog mapping in code?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 22-Jul-2006 12:42:43   

Use catalog name overwriting. See "Using the generated code -> Application configuration through config files"

Frans Bouma | Lead developer LLBLGen Pro
ElQueso avatar
ElQueso
User
Posts: 27
Joined: 08-Oct-2005
# Posted on: 26-Jul-2006 05:55:04   

Walaa wrote:

That's because you may add entities from more than one catalog in the same llblgen project. So to define which entity belongs to which catalog, this had to be maintained in code. The connection string can't provide this kind of detail.

Took me awhile to get back to this post. Thanks for the reply.

Of corse! I knew there would be an obvious reason I wasn't seeing...

Rogelio
User
Posts: 221
Joined: 29-Mar-2005
# Posted on: 26-Jul-2006 19:16:36   

austinHodge wrote:

Is there some sort of workaround for this? We have a system that has several databases that are running the same schema. Is there a way to set the catalog mapping in code?

To handle this situation, I do the following:



 Private Shared connString As String = "Password=xxxxxx;Persist Security Info=False;User ID=UserID;Initial Catalog={0};Data Source={1}"

    Public Shared Function GetNewDataAdapter(ByVal serverInfo As DataServerInfo, ByVal keepConnectionOpen As Boolean) As ORM.DataAccessAdapterBase

        Dim adapter As DS.DataAccessAdapter
        Dim conString As String

        conString = String.Format(connString, serverInfo.Database, serverInfo.SqlServer)
        adapter = New DS.DataAccessAdapter(conString, keepConnectionOpen, ORM.CatalogNameUsage.ForceName, serverInfo.Database)

        Return adapter
    End Function

DataServerInfo is a type that has the DataBaseName and SQLServerName.