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


C# SQLiteClient.SqliteConnection类代码示例

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


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


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