Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...multple custom modules connection to same external databasemultple custom modules connection to same external database
Previous
 
Next
New Post
3/28/2013 1:03 PM
 

Hello, Can anyone help me with the following error:
'DotNetNuke.Modules.SistersBirthdays.Data.sistersDBEntities' does not contain a constructor that takes 1 arguments   
from this line in my data service: return new Data.sistersDBEntities(new EntityConnection(DataCache.GetCache(STR_SistersBirthdays_EF_ConnectionString_Key).ToString()));

full data service code:
namespace DotNetNuke.Modules.SistersBirthdays.Service
{
    [System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    public class SistersBirthdaysDataService : DataService<Data.sistersDBEntities>
    {
        // This method is called only once to initialize service-wide policies.
        public static void InitializeService(DataServiceConfiguration config)
        {
            // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
            // Examples:
            config.SetEntitySetAccessRule("*", EntitySetRights.All);
            config.SetServiceOperationAccessRule("*", ServiceOperationRights.AllRead);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
        }

        protected override Data.sistersDBEntities CreateDataSource()
        {
            return CreateModuleDataSource();
        }

        [WebGet]
        public string GetVersion()
        {
            var ver = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            return String.Format("{0}.{1}.{2}.{3}",
                ver.Major, ver.Minor, ver.Build, ver.Revision);
        }

        [WebGet]
        public string GetResourceString(string key)
        {
            return Localization.GetString(key, "/DesktopModules/SistersBirthdays/Views/App_LocalResources/SharedResources.resx");
        }

        private Data.sistersDBEntities CreateModuleDataSource()
        {
            try
            {
                // first check the cache, we only want to do this once
                const string STR_SistersBirthdays_EF_ConnectionString_Key = "SistersBirthdays_EF_ConnectionString_Key";

                if (DataCache.GetCache(STR_SistersBirthdays_EF_ConnectionString_Key) == null)
                {
                    // if not in the cache, construct the entity connection and cache it
                    using (var SiteSQLConnection = new SqlConnection(
                        ConfigurationManager.ConnectionStrings["sistersDBEntities"].ConnectionString))
                    {
                        //check if the connection string has integrated security enabled
                        {
                            bool isIntergratedEnabled = SiteSQLConnection.ConnectionString.Contains("Integrated Security");

                            //Build the Entity Framework connection string from the derived settings
                            var NewSQLConnectionString = new SqlConnectionStringBuilder();
                            var _with1 = NewSQLConnectionString;
                            _with1.DataSource = SiteSQLConnection.DataSource;
                            _with1.InitialCatalog = SiteSQLConnection.Database;
                            if (!isIntergratedEnabled)
                            {
                                string _uid, _pwd = string.Empty;
                                GetUserCredentialsFromConfigFile(SiteSQLConnection.ConnectionString, out _uid, out _pwd);
                                _with1.UserID = _uid;
                                _with1.Password = _pwd;
                            }
                            else
                            {
                                _with1.IntegratedSecurity = isIntergratedEnabled;
                                //.UserInstance = True
                            }
                            _with1.MultipleActiveResultSets = true;

                            var EFConnectionStringBuilder = new EntityConnectionStringBuilder();
                            var _with2 = EFConnectionStringBuilder;
                            _with2.Provider = "System.Data.SqlClient";
                            _with2.ProviderConnectionString = NewSQLConnectionString.ToString();
                            _with2.Metadata = "res://*/Data.sistersDBModel.csdl|res://*/Data.sistersDBModel.ssdl|res://*/Data.sistersDBModel.msl";

                            DataCache.SetCache(STR_SistersBirthdays_EF_ConnectionString_Key, EFConnectionStringBuilder.ToString());
                        }

                    }
                }

                // now establish the connection from the cache
                return new Data.sistersDBEntities(new EntityConnection(DataCache.GetCache(STR_SistersBirthdays_EF_ConnectionString_Key).ToString()));
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }

        }

        private static void GetUserCredentialsFromConfigFile(string strConn, out string userid, out string password)
        {
            var s = new SqlConnectionStringBuilder(strConn);
            userid = s.UserID;
            password = s.Password;
            return;
        }
    }
}

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...multple custom modules connection to same external databasemultple custom modules connection to same external database


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out