Jump to content

How to set connection strings at run time?

  • Please log in to reply
1 reply to this topic

#1 Guest_Bill_*

  • Guests

Posted 03 January 2005 - 08:46 AM

ONe of the reqts of our project is the ability to choose one of N identical databases at run time. This is done for scalability, so for example, if the user comes from the US, then use database 1, if from Europe, then database 2, and so on.

I was told this was possible with some limitations during the evaluation period, but have unfortunately lost my notes on that topic. Something about generating a non-GAC project and then placing all the objects in an assembly of our own creation? Can\'t remember.

CAn you refresh my memory? THanks.

-Bill Barnum

#2 Guest_Paul_*

  • Guests

Posted 03 January 2005 - 08:50 AM


TierDeveloper handles connection string differently depending on the type of components you have built. For serviced components, you can specify a different connection string through "component services" for the "activation-string" property.

In case of NON GAC/NOT MTC components TierDeveloper provides a constructor for accepting a connection string in the factory classes. However, there is no limitation for specifying the connection string during evaluation period. To specify the connection string you need to follow these steps: -
  • Generate & Build Non NonGAC/NonMTS components from the TierDeveloper.
  • Open the file PROJECTNAME.dll.Config (PROJECTNAME is the name of your TierDeveloper project) where the components are generated and edit your own connection string or modify the existing one.
  • Open the component files in any Editor of your choice e.g., .NET IDE.
  • Add the following lines of code in the default constructor of factory class.
    public ProductFactory() : base("", TDevFramework.EDBProvider.OLEDB))


    // Use the Connection String Key name in the AppSettings that you defined in the
  • Once you have modified the code you need to build the components again. It would be better if you use TierDeveloper to build the components.
  • Once your application is built, you need to copy the proj.dll.Config file from the components location to WinForm Application's "bin" folder (in case of win forms) or paste to Web Application folder (in case you have generated Web Application).
  • Now you can execute your web/win application. And can also modify the connection string parameters from the config file.
I hope this will solve your problem.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users