• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SQLiteClient.SqliteConnection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Community.CsharpSqlite.SQLiteClient.SqliteConnection的典型用法代码示例。如果您正苦于以下问题:C# SqliteConnection类的具体用法?C# SqliteConnection怎么用?C# SqliteConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SqliteConnection类属于Community.CsharpSqlite.SQLiteClient命名空间,在下文中一共展示了SqliteConnection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OurMediaItem

 public OurMediaItem(Community.CsharpSqlite.SQLiteClient.SqliteConnection conn, int id)
 {
     // TODO: Complete member initialization
     this.conn = conn;
     this.id = id;
     checked_to_patron_id = -1;
 }
开发者ID:taxilian,项目名称:some_library,代码行数:7,代码来源:OurMediaItem.cs


示例2: save

        public void save(SqliteConnection conn)
        {
            string command;
            if (id == -1)
                command = "insert into mediaitem (name, type, checked_to_patron_id, " +
                          " checkout_date, due_date) values (@name, @type, @patron_id, @co_date, @due_date);";
            else
                command = "update mediaitem set [email protected], [email protected], [email protected]_id, " +
                          " [email protected]_date, [email protected]_date where [email protected]";
            SqliteCommand cmd = new SqliteCommand(command, conn);
            cmd.Parameters.Add("@id", id);
            cmd.Parameters.Add("@name", name);
            cmd.Parameters.Add("@type", type);
            if (checked_to_patron_id > -1)
                cmd.Parameters.Add("@patron_id", checked_to_patron_id);
            else
                cmd.Parameters.Add("@patron_id", null);
            if (checkout_date != null)
                cmd.Parameters.Add("@co_date", checkout_date.Value.ToString());
            else
                cmd.Parameters.Add("@co_date", null);
            if (due_date != null)
                cmd.Parameters.Add("@due_date", due_date);
            else
                cmd.Parameters.Add("@due_date", null);

            cmd.ExecuteNonQuery();
            //id = cmd.LastInsertRowID();
        }
开发者ID:taxilian,项目名称:some_library,代码行数:29,代码来源:OurMediaItem.cs


示例3: Update

 public void Update(SqliteConnection connection, int currentVersion)
 {
     foreach (var script in _scripts.Skip(currentVersion))
     {
         script.Apply(connection);
     }
 }
开发者ID:Irdis,项目名称:VSTalk,代码行数:7,代码来源:MigrationService.cs


示例4: ExecuteCommand

        /// <summary>
        /// Execute command on the database, commands are serialized
        /// </summary>
        /// <param name="database"></param>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public static IEnumerable<SqliteDataReader> ExecuteCommand(string database, string commandText)
        {
            SqliteConnection conn;
            if (!_Connection.TryGetValue(database, out conn))
            {
                conn = new SqliteConnection(SqliteConnectionManager.GetConnectionString(database));
                conn.Open();
                _Connection.Add(database, conn);
            }

            lock (conn)
            {
                var command = conn.CreateCommand();
                command.CommandText = commandText;

                using (var result = command.ExecuteReader())
                {
                    while (result.Read())
                    {
                        yield return result;
                    }
                }

                command.Dispose();
            }
        }
开发者ID:Clancey,项目名称:Wp7Sqlite,代码行数:32,代码来源:ConnectionManager.cs


示例5: CodeProjectDatabase

        public CodeProjectDatabase()
        {
            dbPath = "items.db3";

            IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
            bool exists = isf.FileExists(dbPath);

            var connection = new SqliteConnection("data source=" + dbPath);
            connection.Open();
                
            if (!exists)
            {
                var commands = new[]{
					"CREATE TABLE [Member] (Key integer, Name ntext, ArticleCnt integer, BlogCnt integer, Reputation ntext, IsMe integer);"
				};
                foreach (var command in commands)
                {
                    using (var c = connection.CreateCommand())
                    {
                        c.CommandText = command;
                        c.ExecuteNonQuery();
                    }
                }
            }

        }
开发者ID:Trojka,项目名称:monoCPVanity,代码行数:26,代码来源:CodeProjectDatabase.WP7.cs


示例6: CreateConnection

        protected override ICSDbConnection CreateConnection()
        {
            SqliteConnection conn = new SqliteConnection(ConnectionString);

            conn.Open();
            
            return new CSSqliteConnection(conn);
        }
开发者ID:TheMouster,项目名称:coolstorage,代码行数:8,代码来源:CSDataProviderSqliteWinRT.cs


示例7: CreateSchema

 /// <summary>
 /// Create schema of sync source table
 /// supports transaction
 /// </summary>
 /// <param name="con"></param>
 public static void CreateSchema(SqliteConnection con)
 {
     using (SqliteCommand cmd = con.CreateCommand())
     {
         cmd.CommandText = "CREATE TABLE IF NOT EXISTS " + Configuration.TBL_DATASOURCE_INFO +
                          " ( " + Configuration.COL_SOURCE_ABSOLUTE_PATH + " TEXT, " +
                          Configuration.COL_SOURCE_ID + " TEXT PRIMARY KEY)";
         cmd.ExecuteNonQuery();
     }
 }
开发者ID:nydehi,项目名称:onesync,代码行数:15,代码来源:SQLiteSyncSourceProvider.cs


示例8: ExecuteNonQuery

        public static int ExecuteNonQuery(string sql)
        {
            using (SqliteConnection connection = new SqliteConnection())
            {
                connection.ConnectionString = ConnectionString;
                System.Data.IDbCommand cmd = connection.CreateCommand();
                cmd.CommandText = sql;

                connection.Open();
                return cmd.ExecuteNonQuery();
            }
        }
开发者ID:pisceanfoot,项目名称:codeshare,代码行数:12,代码来源:SQLHepler.cs


示例9: Update

 /// <summary>
 /// Update details of sync source
 /// Pass SQLiteConnection object to make atomic action
 /// </summary>
 /// <param name="source"></param>
 /// <param name="con"></param>
 /// <returns></returns>
 public static bool Update(SyncSource source, SqliteConnection con )
 {
     using (SqliteCommand cmd = con.CreateCommand())
     {
         cmd.CommandText = "UPDATE " + Configuration.TBL_DATASOURCE_INFO +
                 " SET " + Configuration.COL_SOURCE_ABSOLUTE_PATH + " = @path WHERE "
                 + Configuration.COL_SOURCE_ID + " = @id";
         cmd.Parameters.Add(new SqliteParameter("@id", DbType.String) { Value = source.ID });
         cmd.Parameters.Add(new SqliteParameter("@path", DbType.String) { Value = source.Path });
         cmd.ExecuteNonQuery();
         return true;
     }
 }
开发者ID:nydehi,项目名称:onesync,代码行数:20,代码来源:SQLiteSyncSourceProvider.cs


示例10: Add

 /// <summary>
 /// This method takes in SQLiteConnection object as a parameter
 /// </summary>
 /// <param name="s"></param>
 /// <param name="con"></param>
 /// <returns></returns>
 public static bool Add(SyncSource s, SqliteConnection con)
 {
     using (SqliteCommand cmd = con.CreateCommand())
      {
          cmd.CommandText = "INSERT INTO " + Configuration.TBL_DATASOURCE_INFO +
                          "(" + Configuration.COL_SOURCE_ID + "," + Configuration.COL_SOURCE_ABSOLUTE_PATH +
                          ") VALUES (@id, @path)";
          cmd.Parameters.Add(new SqliteParameter("@id", DbType.String) { Value = s.ID });
          cmd.Parameters.Add(new SqliteParameter("@path", DbType.String) { Value = s.Path });
          cmd.ExecuteNonQuery();
      }
      return true;
 }
开发者ID:nydehi,项目名称:onesync,代码行数:19,代码来源:SQLiteSyncSourceProvider.cs


示例11: Initialize

        public override bool Initialize(Framework.Interfaces.ICore core)
        {
            core.LanguageItems.Add(new Framework.Data.LanguageItem(STR_LOADING));
            core.LanguageItems.Add(new Framework.Data.LanguageItem(STR_LOADINGDATA));
            core.LanguageItems.Add(new Framework.Data.LanguageItem(STR_LOADINGGEOCACHES));
            core.LanguageItems.Add(new Framework.Data.LanguageItem(STR_LOADINGLOGS));
            core.LanguageItems.Add(new Framework.Data.LanguageItem(STR_LOADINGLOGIMAGES));
            core.LanguageItems.Add(new Framework.Data.LanguageItem(STR_LOADINGWAYPOINTS));
            core.LanguageItems.Add(new Framework.Data.LanguageItem(STR_SAVING));
            core.LanguageItems.Add(new Framework.Data.LanguageItem(STR_SAVINGDATA));
            core.LanguageItems.Add(new Framework.Data.LanguageItem(STR_SAVINGGEOCACHES));
            core.LanguageItems.Add(new Framework.Data.LanguageItem(STR_SAVINGLOGS));
            core.LanguageItems.Add(new Framework.Data.LanguageItem(STR_SAVINGLOGIMAGES));
            core.LanguageItems.Add(new Framework.Data.LanguageItem(STR_SAVINGLOGIMAGES));
            core.LanguageItems.Add(new Framework.Data.LanguageItem(STR_SAVINGWAYPOINTS));

            if (Properties.Settings.Default.UpgradeNeeded)
            {
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.UpgradeNeeded = false;
                Properties.Settings.Default.Save();
            }
            if (string.IsNullOrEmpty(Properties.Settings.Default.ActiveDataFile))
            {
                Properties.Settings.Default.ActiveDataFile = System.IO.Path.Combine(core.PluginDataPath, "InternalStorage.db3" );
                Properties.Settings.Default.Save();
            }
            try
            {
                string fld = System.IO.Path.GetDirectoryName(Properties.Settings.Default.ActiveDataFile);
                if (!System.IO.Directory.Exists(fld))
                {
                    System.IO.Directory.CreateDirectory(fld);
                }
                _dbcon = new SqliteConnection(string.Format("data source=file:{0}", Properties.Settings.Default.ActiveDataFile));
                InitDatabase(_dbcon);
            }
            catch
            {
                _dbcon = null;
            }

            SetDataSourceName(Properties.Settings.Default.ActiveDataFile);
            core.Logs.LoadFullData += new Framework.EventArguments.LogEventHandler(Logs_LoadFullData);
            core.Geocaches.LoadFullData += new Framework.EventArguments.GeocacheEventHandler(Geocaches_LoadFullData);

            bool result = base.Initialize(core);
            return result;
        }
开发者ID:RH-Code,项目名称:GAPP,代码行数:49,代码来源:InternalStorage.cs


示例12: Add

 public bool Add(SyncAction action, SqliteConnection con)
 {
     switch (action.ChangeType)
     {
         case ChangeType.DELETED:
             return InsertDeleteAction((DeleteAction)action);
         case ChangeType.NEWLY_CREATED:
             return InsertCreateAction((CreateAction)action, con);
         case ChangeType.RENAMED:
             return InsertRenameAction((RenameAction)action);
         default:
             // Log error? Throw ex?
             return false;
     }
 }
开发者ID:nydehi,项目名称:onesync,代码行数:15,代码来源:SQLiteSyncActionsProvider.cs


示例13: Open

 /// <summary>
 /// Open a connection to the database.
 /// </summary>
 private void Open()
 {
     if (db == null)
     {
         try
         {
             db = new SqliteConnection(Constants.Database.connectionString);
             db.Open();
         }
         catch (Exception e)
         {
             System.Windows.MessageBox.Show("Error while connecting to Database: \n" + e.Message + "\n" + e.StackTrace);
         }
     }
 }
开发者ID:Frannsoft,项目名称:dnd35encyclopedia,代码行数:18,代码来源:DBHelper.cs


示例14: OpenDatabase

 public static bool OpenDatabase(string dbFileName)
 {
     try
     {
         Log.log("Opening sqlite database connection: "+dbFileName);
         string cs = string.Format("Version=3,uri=file:{0}", dbFileName);
         connection = new SqliteConnection(cs);
         connection.Open();
         trans =  connection.BeginTransaction();
         return true;
     }
     catch (Exception e)
     {
         return false;
     }
 }
开发者ID:Xplo1T,项目名称:l2tower-database-repository,代码行数:16,代码来源:SqliteManager.cs


示例15: getAll

        internal static List<Patron> getAll(SqliteConnection conn)
        {
            List<Patron> plist = new List<Patron>();

            SqliteCommand cmd = new SqliteCommand("select id, name, type from patron order by name", conn);
            SqliteDataReader rdr = cmd.ExecuteReader();
            while (rdr.NextResult())
            {
                OurPatron p = new OurPatron(conn, rdr.GetInt32(0));
                p.name = rdr.GetString(1);
                p.type = (PatronType)rdr.GetInt32(2);
                plist.Add(p);
            }

            return plist;
        }
开发者ID:taxilian,项目名称:some_library,代码行数:16,代码来源:OurPatron.cs


示例16: ConnectToDatabase

        public override void ConnectToDatabase(string connectionString, string migratorName, bool validateTables)
        {
            _connectionString = connectionString;
            string[] s1 = _connectionString.Split(new[] {"Data Source=", ","}, StringSplitOptions.RemoveEmptyEntries);

            s1[0] = s1[0].Remove(0, 7);

            _fileName = Path.GetFileName(s1[0]);
            if (_fileName == s1[0]) //Only add this if we arn't an absolute path already
                _connectionString = string.Format("Data Source=file://{0}", Path.Combine(Util.BasePathCombine(""), _fileName));

            SqliteConnection connection = new SqliteConnection(_connectionString);
            connection.Open();
            var migrationManager = new MigrationManager(this, migratorName, validateTables);
            migrationManager.DetermineOperation();
            migrationManager.ExecuteOperation();
            connection.Close();
        }
开发者ID:velus,项目名称:Async-Sim-Testing,代码行数:18,代码来源:SQLiteDataManager.cs


示例17: ExecuteNonQuery

        /// <summary>
        /// Shortcut to ExecuteNonQuery with SqlStatement and object[] param values
        /// </summary>
        /// <param name="connectionString">SQLite Connection String</param>
        /// <param name="commandText">Sql Statement with embedded "@param" style parameters</param>
        /// <param name="paramList">object[] array of parameter values</param>
        /// <returns></returns>
        public static int ExecuteNonQuery(string connectionString, string commandText, object[] paramList)
        {
            SqliteConnection cn = new SqliteConnection(connectionString);
            IDbCommand cmd = cn.CreateCommand();
            cmd.CommandText = commandText;
            if (paramList != null)
            {
                cmd.CommandText = string.Format(commandText, paramList);
            }

            if (cn.State == ConnectionState.Closed)
                cn.Open();
            int result = cmd.ExecuteNonQuery();
            cmd.Dispose();
            cn.Close();

            return result;
        }
开发者ID:pnhlong,项目名称:fingerPointSys,代码行数:25,代码来源:CsharpSQLiteHelper.cs


示例18: AddMember

		public bool AddMember(CodeProjectMember member)
		{
            var connection = new SqliteConnection("Data Source=" + dbPath);
            connection.Open();

            using (var command = connection.CreateCommand())
            {
                command.CommandText = "SELECT [Key] FROM [Member] WHERE [Key]=" + member.Id;
                var r = command.ExecuteReader();
                if (r.HasRows)
                {
                    using (var uc = connection.CreateCommand())
                    {
                        uc.CommandText = "UPDATE [Member] SET " +
                            " [Name] = '" + member.Name + "'," +
                            " [ArticleCnt] = '" + member.ArticleCount + "'," +
                            " [BlogCnt] = '" + member.BlogCount + "'," +
                            " [Reputation] = '" + member.Reputation + "'," +
                            " WHERE [Key]=" + member.Id;
                        uc.ExecuteNonQuery();
                    }
                }
                else
                {
                    using (var ic = connection.CreateCommand())
                    {
                        ic.CommandText = "INSERT INTO [Member] ([Key], [Name], [ArticleCnt], [BlogCnt], [Reputation])"
                            + " VALUES(" + member.Id + ", '" + member.Name + "', '" + member.ArticleCount + "', '" + member.BlogCount + "', '" + member.Reputation + "')";
                        ic.ExecuteNonQuery();
                    }
                }
            }

            connection.Close();

            FileStorageService storage = new FileStorageService();
            if (member.Avatar != null)
            {
                storage.WriteBytes(member.Avatar, member.Id.ToString());
            }

            return true;
        }
开发者ID:Trojka,项目名称:monoCPVanity,代码行数:43,代码来源:CodeProjectDatabase.WP7.cs


示例19: Apply

 public void Apply(SqliteConnection connection)
 {
     _connection = connection;
     _log.Info("Start updating db");
     _connection.Open();
     try
     {
         CreateVcard();
         SetupVersion();
     }
     catch (Exception e)
     {
         _log.Fatal("Unexpected error", e);
         throw;
     }
     finally
     {
         _connection.Close();
     }
 }
开发者ID:Irdis,项目名称:VSTalk,代码行数:20,代码来源:Migration2.cs


示例20: DatabaseManager

        private DatabaseManager(string dbName, bool test)
        {
            TestMode = test;
            string finalDatabaseName = string.Format("{0}.{1}", dbName, DB_FINAL_EXT);
            using (IsolatedStorageFile dataStorage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (!dataStorage.FileExists(finalDatabaseName))
                    mountDatabase(dataStorage, finalDatabaseName);

                database = new SqliteConnection(string.Format("Version=3,uri=file:{0}", finalDatabaseName));

                idSessionColumn = string.Format("@{0}", SessionViewModel.ID_COLUMN_NAME);
                titleSessionColumn = string.Format("@{0}", SessionViewModel.TITLE_COLUMN_NAME);
                detailsSessionColumn = string.Format("@{0}", SessionViewModel.DETAILS_COLUMN_NAME);
                distanceSessionColumn = string.Format("@{0}", SessionViewModel.DISTANCE_COLUMN_NAME);
                timeSessionColumn = string.Format("@{0}", SessionViewModel.DURATION_COLUMN_NAME);
                averageSpeedSessionColumn = string.Format("@{0}", SessionViewModel.AVERAGE_SPEED_COLUMN_NAME);
                maxSpeedSessionColumn = string.Format("@{0}", SessionViewModel.MAX_SPEED_COLUMN_NAME);
                kcalSessionColumn = string.Format("@{0}", SessionViewModel.KCAL_COLUMN_NAME);
                sportSessionColumn = string.Format("@{0}", SessionViewModel.SPORT_COLUMN_NAME);
                idSessionLocationColumn = string.Format("@{0}", LocationService.SESSION_ID_COLUMN_NAME);
                latLocationColumn = string.Format("@{0}", LocationService.LAT_COLUMN_NAME);
                lngLocationColumn = string.Format("@{0}", LocationService.LNG_COLUMN_NAME);
                dateSessionColumn = string.Format("@{0}", SessionViewModel.DATE_COLUMN_NAME);

                cmd = database.CreateCommand();
                cmd.Parameters.Add(idSessionColumn, null);
                cmd.Parameters.Add(titleSessionColumn, null);
                cmd.Parameters.Add(detailsSessionColumn, null);
                cmd.Parameters.Add(distanceSessionColumn, null);
                cmd.Parameters.Add(timeSessionColumn, null);
                cmd.Parameters.Add(averageSpeedSessionColumn, null);
                cmd.Parameters.Add(maxSpeedSessionColumn, null);
                cmd.Parameters.Add(kcalSessionColumn, null);
                cmd.Parameters.Add(sportSessionColumn, null);
                cmd.Parameters.Add(idSessionLocationColumn, null);
                cmd.Parameters.Add(latLocationColumn, null);
                cmd.Parameters.Add(lngLocationColumn, null);
                cmd.Parameters.Add(dateSessionColumn, null);
            }
        }
开发者ID:lduparc,项目名称:BeRider,代码行数:41,代码来源:DatabaseManager.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Compiler.Expression类代码示例发布时间:2022-05-24
下一篇:
C# SQLiteClient.SqliteCommand类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap