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


C# SQLiteConnectionStringBuilder.ToString方法代码示例

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


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

示例1: Connection

        //Set up the connection with the password
        public static SQLiteConnection Connection(string dbname, string pwd)
        {
            string datasource = dbname;
            SQLiteConnection.CreateFile(datasource);
            //连接数据库
            SQLiteConnection connection = new SQLiteConnection();
            SQLiteConnectionStringBuilder connstr = new SQLiteConnectionStringBuilder();
            connstr.DataSource = datasource;
            connstr.Password = pwd;//设置密码,SQLite ADO.NET实现了数据库密码保护

            //将连接的信息传递给connection
            connection.ConnectionString = connstr.ToString();

            if (connection == null)
            {
                connection = new SQLiteConnection();
                connection.ConnectionString = connstr.ToString();
                connection.Open();
            }
            else if (connection.State == System.Data.ConnectionState.Closed)
            {
                connection.Open();
            }
            else if (connection.State == System.Data.ConnectionState.Broken)
            {
                connection.Close();
                connection.Open();
            }

            return connection;
        }
开发者ID:icegithub,项目名称:csharp-exercise,代码行数:32,代码来源:DBHelper.cs

示例2: DBManager

 public DBManager(String dataSource)
 {
     // build connection string
     SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder();
     builder.DataSource = dataSource;
     connectionString = builder.ToString();
 }
开发者ID:mlnotes,项目名称:correlation,代码行数:7,代码来源:DBManager.cs

示例3: TestQuery

 public void TestQuery()
 {
     var builder = new SQLiteConnectionStringBuilder();
       builder.DataSource = "test.db";
       using (DbConnection connection = new SQLiteConnection(builder.ToString()))
       {
     connection.Open();
     using (var cmd1 = connection.CreateCommand())
     {
       cmd1.CommandText = @"SELECT name FROM sqlite_master WHERE type='table' AND name='table_test';";
       var reader = cmd1.ExecuteReader();
       if (reader.Read())
       {
     var tableName = reader.GetString(0);
     System.Diagnostics.Trace.WriteLine(String.Format("table name={0}", tableName));
       }
       else
       {
     using (var cmd2 = connection.CreateCommand())
     {
       cmd2.CommandText = @"Create Table 'table_test' (num Integer, str)";
       cmd2.ExecuteNonQuery();
     }
       }
     }
       }
 }
开发者ID:terryfan1109,项目名称:win32-test,代码行数:27,代码来源:UnitTest1.cs

示例4: CardRefundPayService

 public CardRefundPayService()
 {
     string localDriver = "C";
     if (Directory.Exists("D:\\"))
     {
         localDriver = "D";
     }
     string dbPath = localDriver + ":\\DataBase\\top4pos.db3";
     if (!File.Exists(dbPath))
     {
         //创建数据库
         SQLiteConnection.CreateFile(dbPath);
     }
     SQLiteConnectionStringBuilder connectionString = new SQLiteConnectionStringBuilder
                                                         {
                                                             DataSource = dbPath,
                                                             Password = "123",
                                                             Pooling = true,
                                                             FailIfMissing = false
                                                         };
     m_SQLiteHelper = new SQLiteHelper(connectionString.ToString());
     //判断表是否存在
     string strSql = "SELECT COUNT(*) FROM sqlite_master where type='table' and name='CardRefundPay'";
     if (!m_SQLiteHelper.Exists(strSql))
     {
         string createTableSql = @"create table CardRefundPay(StoreValueID INTEGER primary key autoincrement, 
                                                         CardNo varchar(50), ShopID varchar(36), 
                                                         TradePayNo varchar(30), 
                                                         PayAmount decimal(12, 4), EmployeeNo varchar(20), 
                                                         DeviceNo varchar(16), IsFixed Integer,
                                                         CreateTime datetime, LastTime datetime);";
         m_SQLiteHelper.ExecuteSql(createTableSql);
     }
 }
开发者ID:hpbaotho,项目名称:top4ever-pos,代码行数:34,代码来源:CardRefundPayService.cs

示例5: SQLiteDescriptor

        /// <summary>
        /// Constructor for talking to a SQLite database.
        /// </summary>
        /// <param name="databasePath">Path to the db file.</param>
        public SQLiteDescriptor(string databasePath)
        {
            if (!StringHelper.IsNonBlank(databasePath))
            {
                throw new ArgumentNullException("databasePath", "Database file path cannot be null/blank.");
            }
            SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder();
            builder.DataSource = _databasePath = databasePath;

            // we want to disable pooling so we don't wind up locking
            // the file indefinitely.
            builder.Pooling = false;
            _usePooling = false;
            // There is no password, so the strings are the same.
            _cleanConnStr = builder.ToString();
            _connectionStr = builder.ToString();
        }
开发者ID:azavea,项目名称:net-dao-sqlite,代码行数:21,代码来源:SQLiteDescriptor.cs

示例6: getSqlLiteDB

 /// <summary>
 /// 获得连接数据库
 /// </summary>
 /// <param name="datasource"></param>
 /// <returns></returns>
 public SQLiteConnection getSqlLiteDB(String datasource)
 {
     SQLiteConnection conn = new SQLiteConnection();
     SQLiteConnectionStringBuilder connstr = new SQLiteConnectionStringBuilder();
     connstr.DataSource = "databases/" + datasource + ".db";
     conn.ConnectionString = connstr.ToString();
     return conn;
 }
开发者ID:seasovl,项目名称:analysisData,代码行数:13,代码来源:SqliteDBHelper.cs

示例7: Storage

        public Storage()
        {
            string datasource = "map.db";

            if (!System.IO.File.Exists(datasource))
                SQLiteConnection.CreateFile(datasource);

            conn = new SQLiteConnection();
            conStr = new SQLiteConnectionStringBuilder();

            conStr.DataSource = datasource;

            conn.ConnectionString = conStr.ToString();

            // open connection;
            conn.Open();

            SQLiteCommand cmd = new SQLiteCommand();
            string sql = string.Empty;
            cmd.Connection = conn;

            sql = "drop table if exists label;";
            cmd.CommandText = sql;
            cmd.ExecuteNonQuery();

            sql = "drop table if exists path;";
            cmd.CommandText = sql;
            cmd.ExecuteNonQuery();

            sql = "drop table if exists quadtree;";
            cmd.CommandText = sql;
            cmd.ExecuteNonQuery();

            sql = "create table label (id INTEGER, data BLOB);";
            cmd.CommandText = sql;
            cmd.ExecuteNonQuery();

            sql = "create table path (id INTEGER, data BLOB);";
            cmd.CommandText = sql;
            cmd.ExecuteNonQuery();

            sql = "create table quadtree (quadkey TEXT, data BLOB);";
            cmd.CommandText = sql;
            cmd.ExecuteNonQuery();

            sql = "create index label_id ON label(id);";
            cmd.CommandText = sql;
            cmd.ExecuteNonQuery();

            sql = "create index path_id ON path(id);";
            cmd.CommandText = sql;
            cmd.ExecuteNonQuery();

            sql = "create index quadtree_quadkey ON quadtree (quadkey);";
            cmd.CommandText = sql;
            cmd.ExecuteNonQuery();
        }
开发者ID:ackratos,项目名称:USTCMap,代码行数:57,代码来源:Storage.cs

示例8: DbTestSqlLiteAdo

		public DbTestSqlLiteAdo()
		{
			SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder {DataSource = PathToDb};
			pConnectionString = builder.ToString();
			Random r = new Random();
			pRandomString = r.NextDouble().ToString();
			bool ok = SetDllDirectory(PathToDll);
			Debug.Assert(ok);
		}
开发者ID:antgraf,项目名称:Embedded-DB-.Net-Performance-Test,代码行数:9,代码来源:DbTestSqlLiteAdo.cs

示例9: BookDataBase

 private BookDataBase()
 {
     conn = new SQLiteConnection();
     connstr = new SQLiteConnectionStringBuilder();
     cmd = new SQLiteCommand();
     connstr.DataSource = dbName;
     conn.ConnectionString = connstr.ToString();
     conn.Open();
 }
开发者ID:leicheng1996,项目名称:eReading,代码行数:9,代码来源:BookDataBase.cs

示例10: LemmaDatabase

        public LemmaDatabase(string fileName)
        {
            SQLiteConnectionStringBuilder connBuilder = new SQLiteConnectionStringBuilder();
            connBuilder.DataSource = fileName;
            connBuilder.Version = 3;

            conn = new SQLiteConnection(connBuilder.ToString());
            conn.Open();
            InitializeDatabase();
        }
开发者ID:drhoet,项目名称:LanguageTools,代码行数:10,代码来源:LemmaDatabase.cs

示例11: SQLite

 static SQLite()
 {
     //var constring = [email protected]"Data Source={_dbPath};Version=3;";
     var constring = new SQLiteConnectionStringBuilder
     {
         DataSource = _dbPath,
         Version = 3,
     };
     Connection = new SQLiteConnection(constring.ToString()) {ParseViaFramework = true};
     //
 }
开发者ID:M1nistry,项目名称:fMod-Modern,代码行数:11,代码来源:SQLite.cs

示例12: DBHandler

        private DBHandler()
        {
            this.connection = new SQLiteConnection();
            string datasource = ConfigurationManager.AppSettings["DataSource"].ToString();
            SQLiteConnectionStringBuilder connstr = new SQLiteConnectionStringBuilder();
            connstr.DataSource = datasource;
            this.connection.ConnectionString = connstr.ToString();
            this.connection.Open();

            this.dataContext = new StudentDataContext(this.connection);
        }
开发者ID:wanghan,项目名称:DriveSchool,代码行数:11,代码来源:DBHandler.cs

示例13: SQLiteUrlTokenStore

        /// <summary>
        /// Initializes a new instance of the SQLiteUrlTokenStore class.
        /// </summary>
        /// <param name="connectionString">The connection string to use when connecting to the database.</param>
        public SQLiteUrlTokenStore(string connectionString)
        {
            this.ConnectionString = connectionString;
            this.EnsureConnectionString();

            SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder(this.ConnectionString);
            builder.DataSource = ResolveDatabasePath(builder.DataSource);
            this.ConnectionString = builder.ToString();

            EnsureDatabase(builder.DataSource);
        }
开发者ID:ChadBurggraf,项目名称:tasty,代码行数:15,代码来源:SQLiteUrlTokenStore.cs

示例14: Initialize

        //Initialize values
        private void Initialize(string db_name, string db_password)
        {
            connectionString = new SQLiteConnectionStringBuilder();
            connectionString.DataSource = db_name;
            connectionString.Version = 3;

            if(!String.IsNullOrEmpty(db_password))
                connectionString.Password = db_password;

            connection = new SQLiteConnection(connectionString.ToString());
        }
开发者ID:o00oo00o,项目名称:MaxwellPortfolio,代码行数:12,代码来源:SQLiteConnector.cs

示例15: ImageCache

 public ImageCache(string filename)
 {
     var builder = new SQLiteConnectionStringBuilder
     {
         BinaryGUID = true,
         DataSource = filename,
         Version = 3
     };
     string connectionString = builder.ToString();
     m_sqlCon = new SQLiteConnection(connectionString);
     m_sqlCon.Open();
 }
开发者ID:OleksandrKulchytskyi,项目名称:VkManager,代码行数:12,代码来源:ImageCache.cs


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