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


C# SQLiteConnectionStringBuilder.Add方法代码示例

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


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

示例1: ProfilingDataSQLiteWriter

		/// <summary>
		/// Creates a new SQLite profiling data provider and opens or creates a new database stored in a file.
		/// </summary>
		public ProfilingDataSQLiteWriter(string fileName, bool profileUnitTests, string[] unitTestNames)
		{
			if (File.Exists(fileName))
				throw new IOException("File already exists!");
			
			SQLiteConnectionStringBuilder conn = new SQLiteConnectionStringBuilder();
			conn.Add("Data Source", fileName);
			conn.Add("New", true);
			// Disable protecting the database on crashes - it's a new database,
			// it may go corrupt if we crash during DB creation. Disabling journalling
			// makes Inserts faster.
			conn.Add("Journal Mode", "OFF");
			conn.Add("Synchronous", "OFF");
			this.connection = new SQLiteConnection(conn.ConnectionString);
			
			this.connection.Open();
			
			InitializeTables();
			
			File.SetAttributes(fileName, FileAttributes.Compressed);
			
			this.profileUnitTests = profileUnitTests;
			this.unitTestNames = unitTestNames;
			
			if (profileUnitTests && unitTestNames == null)
				throw new InvalidOperationException("Please add unit tests to filter!");
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:30,代码来源:ProfilingDataSQLiteWriter.cs

示例2: DatabaseDriver

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="Engine">The string name, for the GetDatabaseEngine() method</param>
        /// <param name="Host">The Database server IP Address</param>
        /// <param name="Port">The Database server Port Number</param>
        /// <param name="DatabaseName">The name of the database</param>
        /// <param name="User">A username, with database privliages</param>
        /// <param name="Pass">The password to the User</param>
        public DatabaseDriver(string Engine, string Host, int Port, string DatabaseName, string User, string Pass)
        {
            // Set class variables, and create a new connection builder
            this.DatabaseEngine = GetDatabaseEngine(Engine);
            DbConnectionStringBuilder Builder;

            // Establish the connection
            if (this.DatabaseEngine == DatabaseEngine.Sqlite)
            {
                // Create the connection
                Builder = new SQLiteConnectionStringBuilder();
                Builder.Add("Data Source", Path.Combine(Program.RootPath, DatabaseName + ".sqlite3"));
                Connection = new SQLiteConnection(Builder.ConnectionString);
            }
            else if (this.DatabaseEngine == DatabaseEngine.Mysql)
            {
                // Create the connection
                Builder = new MySqlConnectionStringBuilder();
                Builder.Add("Server", Host);
                Builder.Add("Port", Port);
                Builder.Add("User ID", User);
                Builder.Add("Password", Pass);
                Builder.Add("Database", DatabaseName);
                Builder.Add("Convert Zero Datetime", "true");
                Connection = new MySqlConnection(Builder.ConnectionString);
            }
            else
            {
                throw new Exception("Invalid Database type.");
            }
        }
开发者ID:roguesupport,项目名称:ControlCenter,代码行数:40,代码来源:DatabaseDriver.cs

示例3: ApplyRestrictedCredentials

        static partial void ApplyRestrictedCredentials(SQLiteConnectionStringBuilder b, bool admin = false)
        {
            //b.Add("InternalHost", "invalidhost");

            b.Add("InternalUser", "user3");
            b.Password = "mypass";
        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:7,代码来源:LOCALPHP.cs

示例4: DatabaseDriver

        public DatabaseDriver()
        {
            this.DatabaseEngine = Config.GetDatabaseEngine();

            DbConnectionStringBuilder Builder;

            if (this.DatabaseEngine == DatabaseEngine.Sqlite)
            {
                Builder = new SQLiteConnectionStringBuilder();
                string FullPath = Path.Combine(Utils.AssemblyPath, Config.GetType<string>("Database", "Database") + ".sqlite3");
                IsNewDatabase = !File.Exists(FullPath) || new FileInfo(FullPath).Length == 0;

                Builder.Add("Data Source", FullPath);

                Connection = new SQLiteConnection(Builder.ConnectionString);
            }
            else if (this.DatabaseEngine == DatabaseEngine.Mysql)
            {
                Builder = new MySqlConnectionStringBuilder();

                Builder.Add("Server", Config.GetType<string>("Database", "Hostname"));
                Builder.Add("Port", Config.GetType<int>("Database", "Port"));
                Builder.Add("User ID", Config.GetType<string>("Database", "Username"));
                Builder.Add("Password", Config.GetType<string>("Database", "Password"));
                Builder.Add("Database", Config.GetType<string>("Database", "Database"));

                Connection = new MySqlConnection(Builder.ConnectionString);
            }
            else
            {
                throw new Exception("Invalid Database type.");
            }
        }
开发者ID:JohannesHei,项目名称:LoginEmulator,代码行数:33,代码来源:DatabaseDriver.cs

示例5: DatabaseDriver

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="Engine">The string name, from the GetDatabaseEngine() method</param>
        /// <param name="Host">The Database server IP Address</param>
        /// <param name="Port">The Database server Port Number</param>
        /// <param name="DatabaseName">The name of the database</param>
        /// <param name="User">A username, with database privliages</param>
        /// <param name="Pass">The password to the User</param>
        public DatabaseDriver(string Engine, string Host, int Port, string DatabaseName, string User, string Pass)
        {
            // Set class variables, and create a new connection builder
            this.DatabaseEngine = GetDatabaseEngine(Engine);
            DbConnectionStringBuilder Builder;

            if (this.DatabaseEngine == DatabaseEngine.Sqlite)
            {
                string FullPath = Path.Combine(MainForm.Root, DatabaseName + ".sqlite3");
                IsNewDatabase = !File.Exists(FullPath) || new FileInfo(FullPath).Length == 0;
                Builder = new SQLiteConnectionStringBuilder();
                Builder.Add("Data Source", FullPath);
                Connection = new SQLiteConnection(Builder.ConnectionString);
            }
            else if (this.DatabaseEngine == DatabaseEngine.Mysql)
            {
                IsNewDatabase = false;
                Builder = new MySqlConnectionStringBuilder();
                Builder.Add("Server", Host);
                Builder.Add("Port", Port);
                Builder.Add("User ID", User);
                Builder.Add("Password", Pass);
                Builder.Add("Database", DatabaseName);
                Connection = new MySqlConnection(Builder.ConnectionString);
            }
            else
            {
                throw new Exception("Invalid Database type.");
            }
        }
开发者ID:JohannesHei,项目名称:ControlCenter,代码行数:39,代码来源:DatabaseDriver.cs

示例6: OpenConnection

		SQLiteConnection OpenConnection()
		{
			SQLiteConnectionStringBuilder conn = new SQLiteConnectionStringBuilder();
			conn.Add("Data Source", databaseFileName);
			SQLiteConnection connection = new SQLiteConnection(conn.ConnectionString);
			connection.Open();
			return connection;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:8,代码来源:UsageDataUploader.cs

示例7: GetSQLiteConnectionString

        /// <summary>
        /// To get the full SQLite connection string given the SQLite database path
        /// </summary>
        public static string GetSQLiteConnectionString(string dbFileName)
        {
            // returns "Data Source= " + dbFileName + ";New=False;Compress=True;Version=3";
            SQLiteConnectionStringBuilder conn = new SQLiteConnectionStringBuilder();
            conn.DataSource = dbFileName;
            conn.Version = 3;
            conn.FailIfMissing = true;
            conn.Add("Compress", true);

            return conn.ConnectionString;
        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:14,代码来源:SQLiteHelper.cs

示例8: ProfilingDataSQLiteProvider

		/// <summary>
		/// Creates a new SQLite profiling data provider and opens a database stored in a file.
		/// </summary>
		public ProfilingDataSQLiteProvider(string fileName)
		{
			this.nameMappingCache = new Dictionary<int, NameMapping>();
			
			SQLiteConnectionStringBuilder conn = new SQLiteConnectionStringBuilder();
			conn.Add("Data Source", fileName);
			this.connection = new SQLiteConnection(conn.ConnectionString);
			
			this.connection.Open();
			
			CheckFileVersion();
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:15,代码来源:ProfilingDataSQLiteProvider.cs

示例9: GetConnectionString

        private static string GetConnectionString(string dbPath)
        {
            var connectionBuilder = new SQLiteConnectionStringBuilder();

            connectionBuilder.DataSource = dbPath;
            connectionBuilder.CacheSize = (int)-10.Megabytes();
            connectionBuilder.DateTimeKind = DateTimeKind.Utc;
            connectionBuilder.JournalMode = OsInfo.IsOsx ? SQLiteJournalModeEnum.Truncate : SQLiteJournalModeEnum.Wal;
            connectionBuilder.Pooling = true;
            connectionBuilder.Version = 3;

            if (OsInfo.IsOsx)
            {
                connectionBuilder.Add("Full FSync", true);
            }

            return connectionBuilder.ConnectionString;
        }
开发者ID:drewfreyling,项目名称:NzbDrone,代码行数:18,代码来源:ConnectionStringFactory.cs

示例10: UsageDataSessionWriter

		/// <summary>
		/// Opens/Creates the database and starts writing a new session to it.
		/// </summary>
		/// <exception cref="IncompatibleDatabaseException">The database version is not compatible with this
		/// version of the AnalyticsSessionWriter.</exception>
		public UsageDataSessionWriter(string databaseFileName)
		{
			SQLiteConnectionStringBuilder conn = new SQLiteConnectionStringBuilder();
			conn.Add("Data Source", databaseFileName);
			
			connection = new SQLiteConnection(conn.ConnectionString);
			connection.Open();
			try {
				InitializeTables();
				
				StartSession();
			} catch {
				connection.Close();
				throw;
			}
			
			timer = new Timer(OnTimer, 0, TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(60));
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:23,代码来源:UsageDataSessionWriter.cs

示例11: ProfilingDataSQLiteProvider

		/// <summary>
		/// Creates a new SQLite profiling data provider and opens a database stored in a file.
		/// </summary>
		ProfilingDataSQLiteProvider(string fileName, bool allowUpgrade)
		{
			this.nameMappingCache = new Dictionary<int, NameMapping>();
			
			SQLiteConnectionStringBuilder conn = new SQLiteConnectionStringBuilder();
			conn.Add("Data Source", fileName);
			this.connection = new SQLiteConnection(conn.ConnectionString);
			
			try {
				this.connection.Open();
				
				CheckFileVersion(allowUpgrade);
			} catch {
				try {
					connection.Dispose();
				} catch {
					// ignore errors during cleanup, rethrow the first error instead
				}
				throw;
			}
		}
开发者ID:hefnerliu,项目名称:SharpDevelop,代码行数:24,代码来源:ProfilingDataSQLiteProvider.cs

示例12: OpenDatabase

 private void OpenDatabase()
 {
     SQLiteConnectionStringBuilder csb = new SQLiteConnectionStringBuilder();
     csb.Add("data source", "brainstorm.sqlite");
     dbConnection = new SQLiteConnection(csb.ConnectionString);
     dbConnection.Open();
 }
开发者ID:itinerant,项目名称:Brainstorm-csharp,代码行数:7,代码来源:DataAccess.cs


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