Mulitple Database connection string.

Posts   
 
    
shrini
User
Posts: 4
Joined: 13-May-2009
# Posted on: 13-May-2009 15:55:16   

I have recently brought LLBlgen tool for our company and am a bit confused on how to handle multiple database connection strings when I use generated code using self servicing?

When I run a SQL profiler I see that the generated code appends the database name (which might have been dynamically created) but how do I change the connection string based on per user?

Quick response would be highly appreciated.

regards, Shrini

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 13-May-2009 16:29:38   

Please better describe your system. Is this a windows application deployed for each user/client, or a web application?

Does every user or group of users have to access a specific instance of the database on a different server, but having the same catalog name?

Anyway changing the connection string per call/user is a good reason to use Adapter over SelfServicing.

I think the following threads might be helpful to you: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=15875 http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=5288

shrini
User
Posts: 4
Joined: 13-May-2009
# Posted on: 14-May-2009 11:22:45   

Thanks Walla for a quick response. Our is an asp.net application and my query is very similar to the one posted on http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=5288

I did try to manipulate Dbutils (self servicing mode) using the lock mechanism as descibed in the post. Do you also recommend this approach? I feel that I will have to redo this file whenever I try to regenerate the code as it would overwrite my existing changes. I cant put that in User code or included code as this change involves modifying the static createconnection method.

Further is there any better supported way of using self servicing for this instead of actually modifying the generated code?

Regards, Shrinivas Naik

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 14-May-2009 11:39:21   

As Frans explained in the other thread:

The dbUtils template isnt big so you should be able to alter it pretty easily and use your copy in a custom template set

Frans suggested modifying the code just for trial, but your goal should be to modify the template.

shrini
User
Posts: 4
Joined: 13-May-2009
# Posted on: 14-May-2009 14:48:51   

Hi Walla,

I checked the template and I guess its a good method to get my changes to dbutils there, but was curious isn;t there a better way to set teh connection string in the code when we probably use the getmulti() method? Is it something that you would consuider for any future development of LlblGen?

I read in one of the threads you had suggested that its better to use Adapter rather than Self servicing? 1] Is it a big effort to move from self servicing to Adapter base? 2] I already have some custom code which is put in "#region Custom Entity code", does apater specific override these code snippets or would I have to manage it through custom templates as you had suggested? 3] Is there a different way to invoke any Getmutli method when we use adapter specific code? Where do we pass which connectionstring to use?

regards, Shrini

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 14-May-2009 21:39:40   

1) There will be some work involved, yes. Many of the concepts are the same, but you have to get your head around the fact that your entities, and the loading and saving of them are now seperated.

2) Adapter templates still contain custom code regions, but I don't think that they would be preservered if you switched from generating a self-servicing project to adapter - you may need to manually copy them over.

3) GetMulti is not used at all in Adapter - the nearest equivalent is the FetchEntityCollection method of the DataAccessAdapter. Connection strings can be passed to the DataAccessAdapter constructor on initialisation and are then used for the lifetime of the DataAccessAdapter instance.

FWIW I ALWAYS use Adapter myself in the projects that I do. I feel the seperation of the entities from the persistence logic makes it much easier and cleaner to build properly layered applications.

Matt