Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Altering the security model
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
00884917
Message ID:
00885369
Views:
26
Shawn,

>>I would like one database for each company.....instead of 10 security databases.

If I understand you correctly, you want one database for each company, but a single security database for all uers?

If so, MM .NET has functionality that handles this for you. The information you're looking for is in the MM .NET Dev Guide topic "Specifying Database Sets in the Config File".

First of all, you don't need to dynamically change database keys at run time. You can use the same database key for all companies. Instead, you define a DatabaseSet key that is different for each company:

In your application's config file you specify a different database set for each company. Then in the databases element, you specify a connection string to both the "main" application data, and the shared security database.

For example:
<?xml version="1.0" encoding="Windows-1252"?>
<configuration>
  <configSections>
    <section name="databases" type="System.Configuration.NameValueSectionHandler" />
    <section name="databaseSets" type="System.Configuration.NameValueSectionHandler" />
  </configSections>

   <databaseSets>
      <add key="OakLeaf" value="Oak Leaf Enterprises" />
      <add key="WestWind" value="West Wind Technologies" />
      <add key="GeoSektor" value="GeoSektor Dot Com" />
   </databaseSets>

   <databases>
      <add key="OakLeaf\MainData\Connection" value="server=(local);uid=sa;pwd=;database=OakLeafMainData;" />
      <add key="OakLeaf\Security\Connection" value="server=(local);uid=sa;pwd=;database=Security;" />

      <add key="WestWind\MainData\Connection" value="server=(local);uid=sa;pwd=;database=WestWindMainData;" />
      <add key="WestWind\Security\Connection" value="server=(local);uid=sa;pwd=;database=Security;" />

      <add key="GeoSektor\MainData\Connection" value="server=(local);uid=sa;pwd=;database=GeoSektorMainData;" />
      <add key="OakLeaf\Security\Connection" value="server=(local);uid=sa;pwd=;database=Security;" />
   </databases>

  <system.windows.forms jitDebugging="true" />
</configuration>
NOTE: Follow the instructions in the Dev Guide carefully...you need to specify a few other settings like "configSections" and "DatabaseSetDefault" in the config file.

If I understand your scenario correctly, you should probably create a "company" field in your user table. When a user logs in, you can read this information and set the application's "current" DatabaseSet. For example:
mmAppBase.DatabaseMgr.DatabaseSetKey = [specify database set key here];
Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform