how to set connectionString

Posts   
 
    
PierreCB
User
Posts: 13
Joined: 24-Jul-2020
# Posted on: 19-May-2021 23:42:43   

I've been looking for a long time why the code reacts like this. LLBLGen Pro Runtime Framework with LLBLGenPro V5.8.1 SelfServicing.TowClasses With visual Studio 2017 Framework .NET 4.6.1

Here is my code:

    Estimation.Business.DaoClasses.CommonDaoBase.ActualConnectionString = "data source=PC-PIERRE\SQLEXPRESSDEV;initial catalog=Expertisa;integrated security=SSPI;persist security info=False"


    Dim item As New Estimation.Business.EntityClasses.ItemEntity(17162) ' 
    Dim str as String = item.Code

it doesn't matter if I put "catalog=Expertisa", my returned entity always comes from the "ESTIMATION2" database

what am I missing? How can I correct the problem by knowing the cause? The database on which the entity connects is the same as my project "Estimation.Business.llblgenproj"

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 20-May-2021 09:29:21   

The catalog you specify in the connection string is the one used to connect to SQL Server. We generate the catalog name in the mapping data as you can have multiple catalogs in a project.

You can either use catalog name overwriting at runtime (https://www.llblgen.com/Documentation/5.8/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/gencode_applicationconfiguration.htm#catalog-name-overwriting-sql-server-mysql or https://www.llblgen.com/Documentation/5.8/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/gencode_runtimeconfiguration.htm#multi-tenancy-support-catalog-name-overwriting-sql-server-mysql )

Or you can rename the catalog in the catalog explorer in the designer, before code generation.

If you rename the catalog you have (ESTIMATION2) to "" (the empty string), no catalog name is emitted in the SQL query and the one you connect with (in your case Expertisa) will be used.

Frans Bouma | Lead developer LLBLGen Pro
PierreCB
User
Posts: 13
Joined: 24-Jul-2020
# Posted on: 20-May-2021 13:58:05   

About this... the ok button is not available when I rename ESTIMATION2 to an empty string in the Catalog Explorer

Otis wrote:

Or you can rename the catalog in the catalog explorer in the designer, before code generation.

If you rename the catalog you have (ESTIMATION2) to "" (the empty string), no catalog name is emitted in the SQL query and the one you connect with (in your case Expertisa) will be used.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 20-May-2021 15:21:33   

PierreCB wrote:

About this... the ok button is not available when I rename ESTIMATION2 to an empty string in the Catalog Explorer

Otis wrote:

Or you can rename the catalog in the catalog explorer in the designer, before code generation.

If you rename the catalog you have (ESTIMATION2) to "" (the empty string), no catalog name is emitted in the SQL query and the one you connect with (in your case Expertisa) will be used.

it has to have a value. So if you rename it to Expertisa it should work fine. But I think you're better off with runtime catalog name overwriting.

Frans Bouma | Lead developer LLBLGen Pro
PierreCB
User
Posts: 13
Joined: 24-Jul-2020
# Posted on: 20-May-2021 23:05:39   

Thank you :-)