Supply DB ConnectionString to DataSource at runtime

Posts   
 
    
Rhaskins2
User
Posts: 2
Joined: 05-Jun-2009
# Posted on: 05-Jun-2009 15:32:55   

I have a situation where I need to be able to provide the database connection string to an LLBLGenProDataSource at runtime.

Can this be done? I have spent some time looking and have not found the way to make this happen.

Thanks for the help!

Rebecca

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 05-Jun-2009 19:12:27   

Hi Rebecca,

When LivePersistance is set to true, thers is not much you can do, as LLBLGenProDataSource open a new instance of DataAccessAdapter when fetch or persist. So, you need to set the LivePersistance flag to false, and Intercept activity. In that methods (PerformSelect and PerformWork) you need to instantiate the DataAccessAdapter (if using Adapter TemplateSet) using your connectionString.

Are you using Adapter or SelfServicing? Please let us know if you need further help.

David Elizondo | LLBLGen Support Team
Rhaskins2
User
Posts: 2
Joined: 05-Jun-2009
# Posted on: 05-Jun-2009 22:03:08   

Hi David,

I am using the SelfServicing template for my LLBLGenPro objects. I do have LivePersistance set to False.

I am not finding the DataAccessAdapter in my datasource or my event args, and I see that SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase is marked as MustInherit (I'm using VB.NET)

Do I need to create my own DataAccessAdapter class based on the DataAccessAdapterBase class, or am I not finding the correct properties/methods?

Thanks, Rebecca

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 06-Jun-2009 04:22:11   

Hi Rebecca,

Ok. The info I gave you is for Adapter Templateset (I didn't know what were you using simple_smile ). Ok, for SelfServicing, use the DBUtils functionallity.

David Elizondo | LLBLGen Support Team
absintpm
User
Posts: 22
Joined: 12-Jun-2007
# Posted on: 16-Sep-2009 09:48:06   

Hi,

I've got into the very same situation. We need to set the connection string at runtime for a LLBLGenProDataSource used with SelfServicing. We're using different connection strings for reporting than for normal data access scenario. Therefore the DBUtils functionallity is not an option. Any other possibility?

Thanks, Mihai

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 16-Sep-2009 12:07:44   

Please verify me if I'm wrong. You have a web application and you need to switch databases depending on the user loged in.

If that's teh case, then you should be using the Adapter model.

absintpm
User
Posts: 22
Joined: 12-Jun-2007
# Posted on: 16-Sep-2009 12:22:19   

No, we're not switching databases, we were just using a different database user for accessing ad hoc reports because one of the functionalities provided in there was the possibility of editing the SQL query executed. The regular db role used to access the data has read/write access on many tables. Some data is sensitive and user specific. We were already on our way of updating that functionality therefore, removing that layer of security is safe now.

However, just as a question, why don't you offer the possibility setting the connection string on the Data Source in this case?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 16-Sep-2009 12:58:18   

However, just as a question, why don't you offer the possibility setting the connection string on the Data Source in this case?

This could be done if you are using the Adapter model.