public AnagramsRepositorySQL(IAppConfig appConfig)
 {
     _appConfig  = appConfig;
     _connection = new SqlConnection
     {
         ConnectionString = _appConfig.GetConnectionString()
     };
 }
 public UserLogRepository(IAppConfig appConfig)
 {
     _appConfig  = appConfig;
     _connection = new SqlConnection
     {
         ConnectionString = _appConfig.GetConnectionString()
     };
 }
Esempio n. 3
0
        /// <summary>
        /// Gets the live connection string.
        /// </summary>
        /// <returns>
        /// Returns SQL connecting string for live site.
        /// </returns>
        /// <exception cref="System.Exception">Connection string 'live' was empty or not found in the web.config file.</exception>
        public string GetLiveConnectionString()
        {
            var connectionString = _appConfig.GetConnectionString("live");

            if (string.IsNullOrEmpty(connectionString))
            {
                throw new Exception("Connection string 'live' was empty or not found in the web.config file.");
            }

            return(connectionString);
        }
Esempio n. 4
0
        private void BulkCopyToDB(DataTable table)
        {
            using (SqlConnection sourceConnection =
                       new SqlConnection(_appConfig.GetConnectionString()))
            {
                sourceConnection.Open();

                using (SqlBulkCopy bulkCopy =
                           new SqlBulkCopy(_appConfig.GetConnectionString()))
                {
                    bulkCopy.DestinationTableName = "dbo.Words";
                    try
                    {
                        bulkCopy.WriteToServer(table);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
        }