Exemple #1
0
 public SQLDBRepository(SQLDBRepositorySettings settings)
 {
     if (settings == null)
     {
         throw new ArgumentNullException();
     }
     _Settings          = settings;
     _sConnectionString = MakeConnectionString(_Settings);
 }
Exemple #2
0
        public SQLDBRepository(string settingsXmlFileName)
        {
            if (string.IsNullOrEmpty(settingsXmlFileName))
            {
                throw new ArgumentNullException();
            }
            var xml = new XmlSerializer(typeof(SQLDBRepositorySettings));

            using (var sr = new StreamReader(settingsXmlFileName))
            {
                _Settings = xml.Deserialize(sr) as SQLDBRepositorySettings;
            }
            _sConnectionString = MakeConnectionString(_Settings);
        }
Exemple #3
0
 private string MakeConnectionString(SQLDBRepositorySettings settings)
 {
     if (String.IsNullOrEmpty(settings.User))
     {
         if (settings.SQLServerPort != 0)
         {
             return(String.Format(@"data source={0},{2};initial catalog={1};integrated security=True;",
                                  settings.SQLServerAddr,
                                  settings.Database,
                                  settings.SQLServerPort));
         }
         else
         {
             return(String.Format(@"data source={0};initial catalog={1};integrated security=True;",
                                  settings.SQLServerAddr,
                                  settings.Database));
         }
     }
     else
     {
         if (settings.SQLServerPort != 0)
         {
             return(String.Format(@"data source={0},{4};initial catalog={1};UID={2};PWD={3};integrated security=false;",
                                  settings.SQLServerAddr,
                                  settings.Database,
                                  settings.User,
                                  settings.Password,
                                  settings.SQLServerPort));
         }
         else
         {
             return(String.Format(@"data source={0};initial catalog={1};UID={2};PWD={3};integrated security=false;",
                                  settings.SQLServerAddr,
                                  settings.Database,
                                  settings.User,
                                  settings.Password));
         }
     }
 }