当前位置: 首页>>代码示例>>C#>>正文


C# DatabaseType.ToString方法代码示例

本文整理汇总了C#中DatabaseType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# DatabaseType.ToString方法的具体用法?C# DatabaseType.ToString怎么用?C# DatabaseType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DatabaseType的用法示例。


在下文中一共展示了DatabaseType.ToString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetMigration

 private static string GetMigration(DatabaseType type, int version)
 {
     string resourceName = string.Format("Engine.DBMigrations.{0}.{1}.sql", type.ToString(), version);
     Stream resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
     if (resourceStream == null)
         return null;
     using (StreamReader reader = new StreamReader(resourceStream))
     {
         return reader.ReadToEnd();
     }
 }
开发者ID:wdjc100,项目名称:CamLog,代码行数:11,代码来源:DbMigrator.cs

示例2: CreateDatabaseInstance

 public static IData.IDatabase CreateDatabaseInstance(DatabaseType databaseType)
 {
     string dllName = string.Empty;
     if (databaseType == DatabaseType.SqlServer2000
         || databaseType == DatabaseType.SqlServer2005
         || databaseType == DatabaseType.SqlServer2008)
     {
         dllName = "SqlServer";
     }
     else
     {
         dllName = databaseType.ToString();
     }
     return (IData.IDatabase)CreateInstance(dllName, "DataBase");
 }
开发者ID:webxiaohua,项目名称:SmartCodeGen,代码行数:15,代码来源:Factory.cs

示例3: GetMigrationVersions

 private static List<int> GetMigrationVersions(DatabaseType type)
 {
     Assembly ass = Assembly.GetExecutingAssembly();
     string[] resources = ass.GetManifestResourceNames();
     string resourcePrefix = string.Format("Engine.DBMigrations.{0}.", type.ToString());
     List<int> migrationNames = new List<int>();
     foreach (string resourceName in resources)
     {
         if (resourceName.StartsWith(resourcePrefix))
         {
             string[] resourceNameBits = resourceName.Split('.');
             migrationNames.Add(int.Parse(resourceNameBits[resourceNameBits.Length - 2])); // Lose the file extension
         }
     }
     return migrationNames;
 }
开发者ID:wdjc100,项目名称:CamLog,代码行数:16,代码来源:DbMigrator.cs

示例4: CreateDbProvider

        private static DbProvider CreateDbProvider(DatabaseType databaseType, string connectionString) 
        {
            string databaseTypeName = databaseType.ToString();

            ConnectionStringSettings connectionStringSetting = ConfigurationManager.ConnectionStrings[databaseTypeName];

            string providerName = connectionStringSetting.ProviderName;

            string[] assemblyAndClassType = providerName.Split(new char[] { ',' });

            if (assemblyAndClassType.Length.Equals(2))
            {
                return DbProviderFactory.CreateDbProvider(assemblyAndClassType[1].Trim(), 
                                                          assemblyAndClassType[0].Trim(), 
                                                          connectionString);
            }
            else
            {
                return DbProviderFactory.CreateDbProvider(string.Empty, providerName, connectionString);
            }
        }
开发者ID:tu226,项目名称:Eagle,代码行数:21,代码来源:DbGateway.cs

示例5: SetConnectionString

        /// <summary>
        /// Sets a connection string for a website.
        /// </summary>
        /// <param name="name">Name of the website.</param>
        /// <param name="key">Connection string key.</param>
        /// <param name="value">Value for the connection string.</param>
        /// <param name="connectionStringType">Type of connection string.</param>
        public void SetConnectionString(string name, string key, string value, DatabaseType connectionStringType)
        {
            Site website = GetWebsite(name);

            var update = WebsiteManagementClient.WebSites.GetConfiguration(website.WebSpace, website.Name).ToUpdate();

            var csToUpdate = update.ConnectionStrings.FirstOrDefault(cs => cs.Name.Equals(key, StringComparison.OrdinalIgnoreCase));
            if (csToUpdate == null)
            {
                csToUpdate = new WebSiteUpdateConfigurationParameters.ConnectionStringInfo
                {
                    ConnectionString = value,
                    Name = key,
                    Type = connectionStringType.ToString()
                };
                update.ConnectionStrings.Add(csToUpdate);
            }
            else
            {
                csToUpdate.ConnectionString = value;
                csToUpdate.Type = connectionStringType.ToString();
            }

            WebsiteManagementClient.WebSites.UpdateConfiguration(website.WebSpace, website.Name, update);
        }
开发者ID:B-Rich,项目名称:azure-sdk-tools,代码行数:32,代码来源:WebsitesClient.cs

示例6: UnsupportedDatabaseTypeException

 /// <summary>
 /// Initializes a new instance of the <see cref="UnsupportedDatabaseTypeException"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 public UnsupportedDatabaseTypeException(DatabaseType type)
     : base(string.Format(Resources.EXCEPTION_UNSUPPORTED_DATABASETYPE, type.ToString()))
 {
 }
开发者ID:Stoner19,项目名称:Memory-Lifter,代码行数:8,代码来源:Exception.cs

示例7: MakeConnectionString

        /// <summary>
        /// Assembles a OLEDB connection string that can be used to get a database connection.
        /// All the parameters are optional for the purposes of this method, although obviously
        /// it would be possible to create a useless connection string if you leave out important
        /// parameters.
        /// </summary>
        /// <param name="providerType">Database type, will be used to determine provider string.</param>
        /// <param name="server">Server name that is hosting the database</param>
        /// <param name="database">Database name, if necessary to specify</param>
        /// <param name="user">User name to use when accessing the db</param>
        /// <param name="password">Password for above user.</param>
        /// <param name="connectionTimeout">How long to wait before giving up on a command, in seconds.</param>
        /// <returns>A connection string that can be used to create OleDbConnections.</returns>
        public static string MakeConnectionString(DatabaseType providerType, string server,
            string database, string user, string password, int? connectionTimeout)
        {
            string provider;
            if (DatabaseType.SQLSERVER == providerType)
            {
                provider = "SQLOLEDB";
            }
            else if (DatabaseType.ORACLE == providerType)
            {
                provider = "OraOLEDB.Oracle.1";
                // Oracle doesn't want this parameter.
                database = null;
            }
            else if (DatabaseType.ACCESS == providerType)
            {
                provider = "Microsoft.Jet.OLEDB.4.0";
            }
            else
            {
                throw new ArgumentException(providerType + " is an unsupported type of database.", providerType.ToString());
            }

            return MakeConnectionString(provider, server, database, user, password, connectionTimeout);
        }
开发者ID:azavea,项目名称:net-dao-oledb,代码行数:38,代码来源:OleDbDescriptor.cs

示例8: WithDatabaseType

        /// <summary>
        /// Executes expression where it matches any of the provided database types
        /// </summary>
        /// <param name="type">The type</param>
        /// <returns>An expression that can process the requested type</returns>
        public IExecuteExpressionRoot WithDatabaseType(DatabaseType type)
        {
            if ( _context.QuerySchema is IMigrationProcessor)
             {
            var name = _context.QuerySchema.GetType().Name;
            if (!string.IsNullOrEmpty(name))
               name = name.Replace("Processor", "");

            var types = type.ToString()
               .Split(new[] {", "}, StringSplitOptions.None);

            var match = types.FirstOrDefault(t => t == name || t.StartsWith(name));

            if ( match != null)
               return this;
             }

             return new NullExecuteExpression();
        }
开发者ID:garchibald,项目名称:fluentmigrator,代码行数:24,代码来源:ExecuteExpressionRoot.cs

示例9: Remove

        /// <summary>
        /// 从指定文件中删除数据库连接信息。
        /// </summary>
        /// <param name="type">数据库类型</param>
        /// <param name="databaseName">数据库名称</param>
        /// <param name="file">文件路径</param>
        public static void Remove(DatabaseType type, string databaseName, string file = null)
        {
            var xdoument = CreateXDocument(file);

            if (xdoument != null)
            {
                var element = (from x in xdoument.Descendants("database")
                               where
                                   x.Attribute("type").Value == type.ToString() && x.Attribute("name").Value == databaseName
                               select x).FirstOrDefault();

                if (element != null)
                {
                    element.Remove();
                    xdoument.Save(GetFullFilePath(file));
                }
            }
        }
开发者ID:fenglinz,项目名称:Sparrow,代码行数:24,代码来源:ConnectedDatabaseManager.cs

示例10: ExportServerDatabaseToEmbedded

        private void ExportServerDatabaseToEmbedded(DatabaseType databaseType, DatabaseMenuCommandParameters parameters)
        {
            string filter = DataConnectionHelper.GetSqlCeFileFilter();
            Scope scope = Scope.SchemaData;
            if (databaseType == DatabaseType.SQLite)
            {
                filter = DataConnectionHelper.GetSqliteFileFilter();
                scope = Scope.SchemaDataSQLite;
            }
            Debug.Assert(databaseType == DatabaseType.SQLite || databaseType == DatabaseType.SQLCE40, "Unexpected database type");
            try
            {
                string connectionString = parameters.DatabaseInfo != null
                    ? parameters.DatabaseInfo.ConnectionString :
                    DataConnectionHelper.PromptForConnectionString(package);
                if (!string.IsNullOrEmpty(connectionString))
                {
                    PickTablesDialog ptd = new PickTablesDialog();
                    int totalCount = 0;
                    using (IRepository repository = Helpers.DataConnectionHelper.CreateRepository(new DatabaseInfo
                        { ConnectionString = connectionString, DatabaseType = DatabaseType.SQLServer }))
                    {
                        ptd.Tables = repository.GetAllTableNamesForExclusion();
                        totalCount = ptd.Tables.Count;
                    }

                    bool? res = ptd.ShowModal();
                    if (res.HasValue && res.Value == true && (ptd.Tables.Count < totalCount))
                    {
                        string dbName;
                        string dbConnectionString = null;
                        SaveFileDialog fd = new SaveFileDialog();
                        fd.Title = "Export as";
                        fd.Filter = filter;
                        fd.OverwritePrompt = true;
                        fd.ValidateNames = true;
                        bool? result = fd.ShowDialog();
                        if (result.HasValue && result.Value == true)
                        {
                            dbName = fd.FileName;
                            try
                            {
                                if (databaseType == DatabaseType.SQLCE40)
                                {
                                    package.SetStatus("Creating SQL Server Compact database...");
                                    SqlCeScripting.SqlCeHelper4 helper = new SqlCeScripting.SqlCeHelper4();
                                    dbConnectionString = string.Format("Data Source={0};Max Database Size=4091", dbName);
                                    if (System.IO.File.Exists(dbName))
                                        File.Delete(dbName);
                                    helper.CreateDatabase(dbConnectionString);
                                }
                                if (databaseType == DatabaseType.SQLite)
                                {
                                    package.SetStatus("Creating SQLite database...");
                                    var helper = new SqliteHelper();
                                    dbConnectionString = string.Format("Data Source={0};", dbName);
                                    if (System.IO.File.Exists(dbName))
                                        File.Delete(dbName);
                                    helper.CreateDatabase(dbConnectionString);
                                }

                                BackgroundWorker bw = new BackgroundWorker();
                                List<object> workerParameters = new List<object>();
                                workerParameters.Add(dbConnectionString);
                                workerParameters.Add(connectionString);
                                workerParameters.Add(ptd.Tables);
                                workerParameters.Add(databaseType.ToString());
                                workerParameters.Add(scope.ToString());

                                bw.DoWork += new DoWorkEventHandler(bw_DoWork);
                                bw.RunWorkerCompleted += (s, ea) =>
                                {
                                    try
                                    {
                                        if (ea.Error != null)
                                        {
                                            Helpers.DataConnectionHelper.SendError(ea.Error, databaseType, false);
                                        }
                                        Helpers.DataConnectionHelper.LogUsage("DatabasesExportFromServer");
                                    }
                                    finally
                                    {
                                        bw.Dispose();
                                    }
                                };
                                bw.RunWorkerAsync(workerParameters);

                            }
                            catch (Exception ex)
                            {
                                Helpers.DataConnectionHelper.SendError(ex, databaseType, false);
                            }
                        }
                   }
                }
            }
            catch (Exception ex)
            {
                Helpers.DataConnectionHelper.SendError(ex, DatabaseType.SQLServer);
            }
//.........这里部分代码省略.........
开发者ID:REALTOBIZ,项目名称:SqlCeToolbox,代码行数:101,代码来源:DatabasesMenuCommandsHandler.cs


注:本文中的DatabaseType.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。