Error in Config saving

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
7/19/2012 6:20:08 AM
Gravatar
Total Posts 18

Error in Config saving

   hello,

I have some problem regarding adding table with the help of config file inside Setup folder of my UI page.

I am using 2 connection string one for mojoportal and other for my project but when my script is running it goes to in same database where mojoportal tables are available.So please tell me how to keep them seperately?and i am using that connection string in my projects also so it's necessary for me to make the database seperately.

7/19/2012 12:23:38 PM
Gravatar
Total Posts 18439

Re: Error in Config saving

you should just add your own connection string in user.config or web.config and read it from there, you should not add a separate web.config file in your feature folder.

ie we have this one for mojoPortal:

<add key="MSSQLConnectionString" value="server=localhost;UID=mojouser;PWD=mojo123;database=mojo" />

but nothing stops you from adding your own for your separate db:

<add key="MyFeatureConnectionString" value="server=localhost;UID=youruser;PWD=yourpassword;database=yourdb" />

public static string GetMyFeatureConnectionString()
        {
            return ConfigurationManager.AppSettings["MyFeatureConnectionString"];

        }

7/20/2012 8:55:46 AM
Gravatar
Total Posts 18

Re: Error in Config saving

hello joe,

Thanks for giving me this idea but i have already added one connectionstring for my database same as you said.And when i am running the projects it shows me that script is running and all the table and storedprocedures goes to the database where mojoportal table is added.

Actually my projects alone contain approx 40 to 50 table so i want it in seperate database.

Thanks

7/20/2012 9:06:03 AM
Gravatar
Total Posts 2253

Re: Error in Config saving

Hi,

Check out the Using a Different Database for a Feature documentation.

I think where you might be going wrong is that the name of the connection string must follow a certain pattern ([FeatureName]_ConnectionString). For instance, if your feature was named "CoolFeature" your connection string must be named "CoolFeature_ConnectionString".

 <add key="CoolFeature_ConnectionString" value="server=localhost;UID=youruser;PWD=yourpassword;database=yourdb" />

public static string GetMyFeatureConnectionString()
        {
            return ConfigurationManager.AppSettings["CoolFeature_ConnectionString"];

        }

Also, your feature folder in the /Setup/Application folder must be named "CoolFeature". The logic in the setup page is to look for the convention based connection string "[FeatureName]_ConnectionString" based on the feature folder name, if it finds a value it passes this in as an override connection string when running the scripts, otherwise it just uses the main connection string.

HTH,
Joe D.

7/21/2012 6:25:07 AM
Gravatar
Total Posts 18

Re: Error in Config saving

Hi,

For all feature i have to add like this,that is for every features different connection string is used.And i am having more than 40 features so i have to write all connectionstring  in web.config and My web.config will become full with connection string.

Is this the right way to use for every features in a project ?

can't we use one connection string for every features ?

And one more thing i want to ask you that for using one table in 2 or more features we should repeat the table in config file of both features or not?So how to use the same table in 2 or more features?

7/21/2012 7:17:10 AM
Gravatar
Total Posts 18439

Re: Error in Config saving

If the built in setup routine doesn't meet you needs then implement your own solution for running your scripts then you can use just one connection string.

7/21/2012 7:27:25 AM
Gravatar
Total Posts 18439

Re: Error in Config saving

Actually you don't need 40 separate connection strings because there is no requirement for a 1 to 1 correspondence between application name and feature,

ie you have one folder /Setup/[yourapplicationname]

this requires only 1 connection string and uses one set of sql scripts

but in the folder /Setup/[yourapplicationname]/FeatureDefinitions

you can define all 40 of your features

You must sign in to post in the forums. This thread is closed to new posts.