Hard coded database name

Posts   
 
    
Dan1
User
Posts: 41
Joined: 20-Sep-2007
# Posted on: 07-Nov-2007 17:39:06   

v2.5 I can change my connection string, but it seems that LLBLGen Pro generates code that hard codes the name of the database in the code. Is there a way around this? Here are some examples of where the database name is hardcoded:

Clearly I can change the connection string, but it still tried to use the database name that is generated (no matter which database I specify in my connection string).

    ''' <summary>Inits View's mappings</summary>
    Private Sub InitAssy_Info_ViewTypedViewMappings()
        MyBase.AddElementMapping( "Assy_Info_ViewTypedView", "WeldQA", "dbo", "vwAssy_Info", 15 )



    ''' <summary>
    ''' Calls stored procedure 'spInspectionsExist_WeldSpec_MigID'.<br/><br/>
    ''' 
    ''' </summary>
    ''' <param name="weldSpec_MigId">Input parameter of stored procedure</param>
    ''' <param name="inspectionsExist">InputOutput parameter of stored procedure</param>
    ''' <returns>Amount of rows affected, if the database / routine doesn't surpress rowcounting.</returns>
    Public Shared Function InspectionsExist_WeldSpec_MigId(weldSpec_MigId As System.Int32, ByRef inspectionsExist As System.Boolean) As Integer
        ' create parameters
        Dim parameters() As SqlParameter = New SqlParameter(2 - 1) {}
        parameters(0) = New SqlParameter("@WeldSpec_MigID", SqlDbType.Int, 0, ParameterDirection.Input, True, 10, 0, "",  DataRowVersion.Current, weldSpec_MigId)
        parameters(1) = new SqlParameter("@InspectionsExist", SqlDbType.Bit, 0, ParameterDirection.InputOutput, True, 1, 0, "",  DataRowVersion.Current, inspectionsExist)
        ' Call the stored proc.
        Dim toReturn As Integer = DbUtils.CallActionStoredProcedure("[WeldQA].[dbo].[spInspectionsExist_WeldSpec_MigID]", parameters, Nothing)
        If Not parameters(1).Value Is System.DBNull.Value Then
            inspectionsExist = CType(parameters(1).Value, System.Boolean)
        End If

        Return toReturn
    End Function
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 08-Nov-2007 04:14:44   

Indeed, LLBLGenPro uses the original catalog name at code. You can change the catalog name via config files. Did you read LLBLGenPro Help - Using generated code - Application configuration through config files - Catalog name overwriting (SqlServer, Sybase ASE) ?

David Elizondo | LLBLGen Support Team
Dan1
User
Posts: 41
Joined: 20-Sep-2007
# Posted on: 08-Nov-2007 14:43:43   

Thanks!!!

j0shu@tree
User
Posts: 8
Joined: 07-Jul-2014
# Posted on: 18-Mar-2016 11:02:44   

Found it..sorry...

But how would the .config file look??



  <configSections>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
    
<configSections>
    <section name="ConnectionString.RIS" type="System.Configuration.NameValueSectionHandler" />
</configSections>

<sqlServerCatalogNameOverwrites>
    <add key="RIS001" value="RIS001Prod" />
</sqlServerCatalogNameOverwrites>


    </sectionGroup>
    
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
  </startup>

  <appSettings>
    <add key="ConnectionString.RIS" value="data source=;initial catalog=RIS001;.."/>
    <add key="ClientSettingsProvider.ServiceUri" value="" />
  </appSettings>



Jos

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 18-Mar-2016 15:51:29   

You add these elements to your application's app./web.config file, configSections at the top.

Frans Bouma | Lead developer LLBLGen Pro