CodeGarden 10: The sixth annual Umbraco Developer Conference
June 23-25th 2010 - free ASP.NET MVC pre-conference. Register today!

connecting to multiple databases

2/9/2010 12:35:00 AMAvatarf10xLocation: Melbourne 3000, Australiaposts: 21Karma: 18

Hi All,

We are struggling with a few database issues and hope that the Umbraco community could shed some light on a few of these issues.

One of the portals we are working on needs to connect to a couple of databases. This is becasue:

One database has user login details

The other has application and user specific data.

We have tried adding multiple connection strings in the Umbraco template, however, this does not work.

Umbraco seems to connect to the very first connection string.

Any suggestions or links to resources would be great.

 

Thank  you for y our time and help.

 

 

 

 

 

 

2/9/2010 5:51:57 AMAvatarRichard SoetemanLocation: 2102LB, The NetherlandsVendor.posts: 692Karma: 1412
Comment with ID: 25736

Hi,

Before you start make sure there is absolutly no other way to use 1 database.

What you could do is writing a Custom Memership provider for this. In the custom membership provider you use the database that holds the member/umbraco user information. The default database holds the data.

Umbraco uses the normal user and member objects under the hood so you have to build a provider from scratch.

Few references online to check.

Tim's blog http://www.nibble.be/?p=66
MSDN: msdn.microsoft.com/en-us/library/f1kyba5e.aspx

Hope this helps you,

Richard

2/9/2010 8:57:27 AMAvatarDirk De GraveLocation: LotenhulleMVP.admin.posts: 2941Karma: 2904
Comment with ID: 25747

As Richard points out, using a custom membership provider for user logins is a good start. Besides that, you can use multiple db's, and you can easily use the umbraco framework to connect to other databases

using (var sqlHelper = DataLayerHelper.CreateSqlHelper(_connectionstring)) {...}

will allow you to use the 'umbraco data layer' to connect to any database.

 

Hope this helps.

Regards,

/Dirk

Please login or Sign up To post replies