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

C# Sqlite.SqliteCommand类代码示例

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

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



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

示例1: Init

        public static void Init(string databaseFullPath)
        {
            try
            {
                if (!File.Exists(databaseFullPath))
                {
                    throw new Exception("Could not find the cards database.");
                }

                _cards = new Dictionary<int, NamedCard>();

                using (SqliteConnection connection = new SqliteConnection("Data Source=" + databaseFullPath))
                {
                    connection.Open();

                    using (IDbCommand command = new SqliteCommand(
                        "SELECT datas.id, ot, alias, setcode, type, level, race, attribute, atk, def, texts.name, texts.desc"
                        + " FROM datas INNER JOIN texts ON datas.id = texts.id",
                        connection))
                    {
                        using (IDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                LoadCard(reader);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Could not initialize the cards database. Check the inner exception for more details.", ex);
            }
        }
开发者ID:mycard,项目名称:ygosharp,代码行数:35,代码来源:NamedCardsManager.cs


示例2: DoNonQuery

		public static int DoNonQuery (SqliteConnection connection, string command_text, string[] param_names, object[] param_args)
		{
			int ret = 0;

			using (SqliteCommand command = new SqliteCommand ()) {
				command.Connection = connection;
				command.CommandText = command_text;

				if (param_names != null) {
					if (param_args == null || param_names.Length != param_args.Length)
						throw new ArgumentException ("param_names, param_args", "param_names and param_args should have same number of items");
					for (int i = 0; i < param_names.Length; ++i)
						command.Parameters.AddWithValue (param_names [i], param_args [i]);
				}

				while (true) {
					try {
						ret = command.ExecuteNonQuery ();
						break;
					} catch (SqliteException e) {
						if (e.ErrorCode == SQLiteErrorCode.Busy) {
							Thread.Sleep (50);
						} else {
							throw;
						}
					} catch (Exception e) {
						Log.Error (e, "SQL that caused the exception: {0}", command_text);
						throw;
					}
				}
			}

			return ret;
		}
开发者ID:zweib730,项目名称:beagrep,代码行数:34,代码来源:SqliteUtils.cs


示例3: Init

        public static void Init()
        {
            try
            {
                _cards = new Dictionary<int, CardData>();

                string currentPath = Assembly.GetExecutingAssembly().Location;
                currentPath = Path.GetDirectoryName(currentPath) ?? "";
                string absolutePath = Path.Combine(currentPath, "cards.cdb");

                if (!File.Exists(absolutePath))
                {
                    throw new Exception("Could not find the cards database.");
                }

                using (SqliteConnection connection = new SqliteConnection("Data Source=" + absolutePath))
                {
                    connection.Open();

                    const string select =
                        "SELECT datas.id, alias, type, level, race, attribute, atk, def, name, desc " +
                        "FROM datas INNER JOIN texts ON datas.id = texts.id";

                    using (SqliteCommand command = new SqliteCommand(select, connection))
                    using (SqliteDataReader reader = command.ExecuteReader())
                        InitCards(reader);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Could not initialize the cards database. Check the inner exception for more details.", ex);
            }
        }
开发者ID:Tic-Tac-Toc,项目名称:windbot,代码行数:33,代码来源:CardsManager.cs


示例4: GetAllCategories

        /// <summary>
        /// Returns all categories.
        /// </summary>
        public IEnumerable<Category> GetAllCategories()
        {
            var categories = new List<Category>();

            using (var connection = new SqliteConnection("Data Source=" + dbPath))
            using (var query = new SqliteCommand("SELECT * FROM Categories", connection))
            {
                connection.Open();

                var reader = query.ExecuteReader(CommandBehavior.CloseConnection);

                while (reader.Read())
                {
                    var category = new Category();
                    category.Id = int.Parse(reader["id"].ToString());
                    category.Name = reader ["name"].ToString();

                    categories.Add(category);
                }

                reader.Close();
            }

            return categories;
        }
开发者ID:CayasSoftware,项目名称:RSSReader,代码行数:28,代码来源:CategoryRepository.cs


示例5: NonQuery

 public void NonQuery( string cmdstr )
 {
     using (var cmd = new SqliteCommand( con )) {
         cmd.CommandText = cmdstr;
         cmd.ExecuteNonQuery();
     }
 }
开发者ID:Money520,项目名称:XR.Baboon,代码行数:7,代码来源:CodeRecordData.cs


示例6: DateTimeConvert

		public void DateTimeConvert ()
		{
			var dateTime = new DateTime (2016, 9, 15, 12, 1, 53);
			var guid = Guid.NewGuid ();

			using (var connection = new SqliteConnection ("Data Source=" + _databasePath)) {
				connection.Open ();

				var sqlCreate = "CREATE TABLE TestTable (ID uniqueidentifier PRIMARY KEY, Modified datetime)";
				using (var cmd = new SqliteCommand (sqlCreate, connection)) {
					cmd.ExecuteNonQuery ();
				}

				var sqlInsert = "INSERT INTO TestTable (ID, Modified) VALUES (@id, @mod)";
				using (var cmd = new SqliteCommand (sqlInsert, connection)) {
					cmd.Parameters.Add (new SqliteParameter ("@id", guid));
					cmd.Parameters.Add (new SqliteParameter ("@mod", dateTime));
					cmd.ExecuteNonQuery ();
				}
			}

			using (var connection = new SqliteConnection ("Data Source=" + _databasePath)) {
				connection.Open ();

				var sqlSelect = "SELECT * from TestTable";
				using (var cmd = new SqliteCommand (sqlSelect, connection))
				using (var reader = cmd.ExecuteReader ()) {
					while (reader.Read ()) {
						Assert.AreEqual (guid, reader.GetGuid (0), "#1");
						Assert.AreEqual (dateTime, reader.GetDateTime (1), "#2");
					}
				}
			}
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:34,代码来源:SqliteTests.cs


示例7: ExecuteStringCommand

        public static List<string[]> ExecuteStringCommand(SqliteCommand command, int columncount)
        {
            try
            {
            var values = new List<string[]>();
            SqliteDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                var row = new List<string>();
                for (int i = 0; i < reader.FieldCount; i++)
                {
                    row.Add(reader[i].ToString());
                }
                values.Add(row.ToArray());
            }
            reader.Close();
            return values;

            }
            catch (Exception ex)
            {
            MessageBox.Show(ex.Message);
            return new List<string[]>();
            }
        }
开发者ID:salvadorc17,项目名称:YGOPRO-Tools,代码行数:25,代码来源:DatabaseHelper.cs


示例8: UpdateOrders

    public void UpdateOrders()
    {
        MainClass.StatusMessage("Получаем таблицу заказов...");

        string sql = "SELECT orders.id, orders.customer, orders.contract, orders.address, orders.phone1, orders.phone2, orders.arrval, orders.deadline_s, orders.deadline_e FROM orders ";
        SqliteCommand cmd = new SqliteCommand(sql, (SqliteConnection) QSMain.ConnectionDB);

        using(SqliteDataReader rdr = cmd.ExecuteReader())
        {
            OrdersListStore.Clear();
            while (rdr.Read())
            {
                OrdersListStore.AppendValues(rdr.GetInt32(rdr.GetOrdinal("id")),
                    rdr["customer"].ToString(),
                    rdr["contract"].ToString(),
                    rdr["phone1"].ToString() + rdr["phone2"].ToString(),
                    rdr["address"].ToString(),
                    String.Format("{0:d}", rdr["arrval"]),
                    DateWorks.GetDateRangeText(DBWorks.GetDateTime(rdr, "deadline_s", new DateTime()), DBWorks.GetDateTime(rdr, "deadline_e", new DateTime()))
                );
            }

        }
        MainClass.StatusMessage("Ok");
    }
开发者ID:QualitySolution,项目名称:CupboardDesigner,代码行数:25,代码来源:MainWinOrders.cs


示例9: GetAllFeeds

        /// <summary>
        /// Returns all subscribed feeds.
        /// </summary>
        public IEnumerable<Feed> GetAllFeeds()
        {
            var feeds = new List<Feed>();

            using (var connection = new SqliteConnection("Data Source=" + dbPath))
            using (var query = new SqliteCommand("SELECT * FROM Feeds", connection))
            {
                connection.Open();

                var reader = query.ExecuteReader(CommandBehavior.CloseConnection);

                while (reader.Read())
                {
                    var feed = new Feed();
                    feed.Id = int.Parse(reader["id"].ToString());
                    feed.Name = reader ["name"].ToString();
                    feed.Url = reader ["url"].ToString();
                    feed.LastUpdated = DateTime.Parse (reader ["LastUpdated"].ToString ());
                    feed.CategoryId = int.Parse(reader["categoryId"].ToString());

                    feeds.Add(feed);
                }

                reader.Close();
            }

            return feeds;
        }
开发者ID:CayasSoftware,项目名称:RSSReader,代码行数:31,代码来源:FeedRepository.cs


示例10: Fill

        public void Fill(int id)
        {
            ItemId = id;
            NewItem = false;

            MainClass.StatusMessage(String.Format ("Запрос выставки №{0}...", id));
            string sql = "SELECT exhibition.* FROM exhibition WHERE exhibition.id = @id";
            try
            {
                SqliteCommand cmd = new SqliteCommand(sql, (SqliteConnection) QSMain.ConnectionDB);

                cmd.Parameters.AddWithValue("@id", id);

                using(SqliteDataReader rdr = cmd.ExecuteReader())
                {
                    rdr.Read();

                    labelID.Text = rdr["id"].ToString();
                    entryName.Text = rdr["name"].ToString();
                    entryPhone1.Text = DBWorks.GetString(rdr, "phone", "");
                    entryPhone2.Text = DBWorks.GetString(rdr, "phone2", "");
                    textAddress.Buffer.Text = DBWorks.GetString(rdr, "address", "");
                }

                MainClass.StatusMessage("Ok");
                this.Title = entryName.Text;
            }
            catch (Exception ex)
            {
                QSMain.ErrorMessageWithLog(this, "Ошибка получения информации о номенклатуре!", logger, ex);
            }
            TestCanSave();
        }
开发者ID:QualitySolution,项目名称:CupboardDesigner,代码行数:33,代码来源:Exhibition.cs


示例11: GetAll

 public IList<SyncItem> GetAll()
 {
     List<SyncItem> returnData = new List<SyncItem>();
     using (var conn = _provider.GetConnection())
     {
         conn.Open();
         using (SqliteCommand command =
             new SqliteCommand(
                 string.Format(
                     @"SELECT Id, FileKey, CloudAssetId,
         CloudLastUpdatedDate, CloudCreatedDate, IsDeleted,
         Size FROM {0}", SyncItem.TableName), conn))
         {
             var reader = command.ExecuteReader();
             while (reader.Read())
             {
                 SyncItem item = new SyncItem();
                 item.Id = reader.GetInt32(0);
                 item.FileKey = reader.GetString(1);
                 item.CloudAssetId = reader.GetString(2);
                 item.CloudLastUpdated = new DateTime(reader.GetInt64(3));
                 item.CloudCreated = new DateTime(reader.GetInt64(4));
                 item.IsDeleted = reader.GetBoolean(5);
                 returnData.Add(item);
             }
         }
         conn.Close();
     }
     return returnData;
 }
开发者ID:KalliopeMedia,项目名称:KalliopeSync,代码行数:30,代码来源:SyncItemServices.cs


示例12: GUIhosts

        public GUIhosts(GUImain gui, SqliteConnection connection, SqliteCommand command)
        {
            InitializeComponent();
            InitializeList();

            this.gui = gui;
            _connection = connection;
            _command = command;

            using (_command = new SqliteCommand("SELECT host, port, password FROM hosts ORDER BY id DESC", _connection))
            {

                using (SqliteDataReader reader = _command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        String host = gui.GetSafeString(reader, 0);
                        String port = gui.GetSafeString(reader, 1);
                        String password = gui.GetSafeString(reader, 2);

                        String[] items = { host, port, password };
                        ListViewItem item = new ListViewItem(items);
                        list.Items.Add(item);
                    }
                }
            }
        }
开发者ID:DomiStyle,项目名称:DaRT,代码行数:27,代码来源:GUIhosts.cs


示例13: addRow

    void addRow(string sName, string sNote)
    {
        SqliteCommand cmd=new SqliteCommand(con);
        cmd.CommandText=
            string.Format("Insert into Cars (id,name,note) VALUES(NULL,'{0}','{1}');",
                          sName,sNote);
        da.InsertCommand=cmd;
        da.InsertCommand.ExecuteNonQuery();

        DataTable dt = ds.Tables[0];
        DataRow dr = dt.NewRow();
        dr["name"]=sName;
        dr["note"]=sNote;
        dr["id"]=getNewID();
        dt.Rows.Add(dr);

        System.Console.WriteLine(da.InsertCommand.CommandText);

        dt.AcceptChanges();
        ds.AcceptChanges();

        da.Update(dt);

        doRefresh();
    }
开发者ID:hjgode,项目名称:mail_grabber,代码行数:25,代码来源:MForm.cs


示例14: Create

		public void Create()
		{
			try {
				if(File.Exists(dbPath)) {
					cnn.Dispose();
					// We want to start with a fresh db for each full run
					// The database is created on the first open()
					File.Delete(dbPath);
				}
			}
			catch(Exception e) {
				throw e;
			}

			try {
				using (var createCommand = new SqliteCommand ("CREATE TABLE Company (RecordId int, Name text);", cnn))
				using (var insertCommand = new SqliteCommand ("INSERT INTO Company VALUES (1, 'Test CO')", cnn)) {
					cnn.Open();
					createCommand.ExecuteNonQuery();
					insertCommand.ExecuteNonQuery();
				}
			}
			catch(Exception e) {
				Console.WriteLine (e);
				throw new AssertionException ("Create table failed", e);
			}
			finally {
				cnn.Close();  
			}
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:30,代码来源:Bug27864.cs


示例15: MakeSureTableExists

		private void MakeSureTableExists()
		{
			using (SqliteCommand sqc = new SqliteCommand(connection)) {
				sqc.CommandText = "CREATE TABLE IF NOT EXISTS `Files` (`id` INTEGER NOT NULL PRIMARY KEY, `path` TEXT NOT NULL, `changedate` INTEGER NOT NULL, `size` INTEGER NOT NULL, `hash` TEXT NOT NULL)";
				sqc.ExecuteNonQuery();
			}
		}
开发者ID:SmartFire,项目名称:IntelliSync,代码行数:7,代码来源:Snapshot.cs


示例16: WriteFiles

		/// <summary>
		/// Write or update files and hashes.
		/// </summary>
		/// <param name="liste"></param>
		public void WriteFiles(List<FileObject> liste)
		{
			using (SqliteTransaction sqt = connection.BeginTransaction()) {
				using (SqliteCommand sqc = new SqliteCommand(connection)) {
					// Alle vorhandenen Einträge löschen, da diese in jedem Fall überschrieben werden sollten
					sqc.CommandText = "DELETE FROM Files WHERE path=:path";
					sqc.Parameters.Add(new SqliteParameter("path"));
					foreach (FileObject d in liste) {
						sqc.Parameters["path"].Value = d.Filepath;
						sqc.ExecuteNonQuery();
					}
					//sqc.Parameters.Clear(); // Nötig?

					// Dateien eintragen
					sqc.CommandText = "INSERT INTO Files (path, hash, size, changedate) VALUES (:path, :hash, :size, :changedate)";
					sqc.Parameters.Add(new SqliteParameter("path"));
					sqc.Parameters.Add(new SqliteParameter("hash"));
					sqc.Parameters.Add(new SqliteParameter("size"));
					sqc.Parameters.Add(new SqliteParameter("changedate"));
					foreach (FileObject d in liste) {
						sqc.Parameters["path"].Value = d.Filepath;
						sqc.Parameters["hash"].Value = d.Hash;
						sqc.Parameters["size"].Value = d.Size;
						sqc.Parameters["changedate"].Value = d.ChangeDate;
						sqc.ExecuteNonQuery();
					}
				}
				sqt.Commit();
			}
		}
开发者ID:SmartFire,项目名称:IntelliSync,代码行数:34,代码来源:Snapshot.cs


示例17: liqviscdata

        private void liqviscdata()
        {

            con.Open();

            string stm = "SELECT * FROM windowsdata WHERE comp='"+comppicker.SelectedItem+"' ORDER BY comp ";

            using (SqliteCommand cmd = new SqliteCommand(stm, con))
            {
                using (SqliteDataReader rdr = cmd.ExecuteReader())
                {
                    while (rdr.Read())
                    {
                        tcenti = double.Parse(temp.Text);
                        tk = tcenti + 273.15;
                        viscb =double.Parse( rdr["viscb"].ToString());
                        viscc = double.Parse(rdr["viscc"].ToString());
                        if (viscc != 0)
                        {
                            double visc1 = viscb * ((1 / tk) - (1 / viscc));
                            double viscocity = Math.Pow(10, visc1);
                            Liqvisc.Text = viscocity.ToString();
                        }
                        else
                        {
                            Liqvisc.Text = "0"; 
                        }
                        
                    }
                }
            }
            con.Close();
        }
开发者ID:sabarinadhamara,项目名称:PCWindows,代码行数:33,代码来源:LiquidViscosity.xaml.cs


示例18: LibraryDatabaseManager

        public LibraryDatabaseManager(String dbFolderPath)
        {
            DatabaseFile = String.Format(dbFolderPath + "{0}Library.db",
                                         Path.DirectorySeparatorChar);
            Connection = new SqliteConnection (
                "Data Source = " + LibraryDatabaseManager.DatabaseFile +
                "; Version = 3;");

            bool exists = File.Exists (LibraryDatabaseManager.DatabaseFile);
            if (!exists) {
                SqliteConnection.CreateFile (LibraryDatabaseManager.DatabaseFile);
            }

            Connection.Open ();
            if (!exists) {
                using (SqliteCommand command = new SqliteCommand (Connection)) {
                    command.CommandText =
                        "CREATE TABLE Books (" +
                            "BookID INTEGER PRIMARY KEY NOT NULL, " +
                            "BookTitle TEXT, " +
                            "BookAuthor TEXT, " +
                            "BookGenre TEXT, " +
                            "BookPublishedYear INTEGER, " +
                            "BookPath TEXT);";
                    command.ExecuteNonQuery();
                }
            }
        }
开发者ID:burtonageo,项目名称:Bookling,代码行数:28,代码来源:LibraryDatabaseManager.cs


示例19: Delete

        public bool Delete(Guid presentationUID)
        {
            bool ret = false;

            if (presentationUID == Guid.Empty)
                return false;

            using (SqliteConnection conn = GetConnection())
            {
                using (SqliteCommand sqlCmd = new SqliteCommand(@"
                    BEGIN; " +
                    "DELETE FROM presentations " +
                    "WHERE [email protected];" +
                    "COMMIT;", conn))
                {
                    sqlCmd.Parameters.AddWithValue("@PresentationUID", presentationUID.ToString());

                    conn.Open();

                    try
                    {
                        sqlCmd.ExecuteNonQuery();
                        ret = true;
                    }
                    catch (SqliteException ex)
                    {
                        Logging.Log(this, Logging.LoggingTypeError, "SQL cmd: " + sqlCmd, ex);
                    }

                    conn.Close();
                }
            }

            return ret;
        }
开发者ID:00091701,项目名称:FullscreenPresentation-Mono,代码行数:35,代码来源:DBPresentation.cs


示例20: CommitTransaction

        public void CommitTransaction()
        {
            var lst = new List<string>();
            using (var cmd = new SqliteCommand(String.Format("SELECT DISTINCT [TableName] FROM {0}", TranStatusTable), ActiveConnection))
            {
                using (SqliteDataReader r = cmd.ExecuteReader())
                {
                    while (r.Read())
                    {
                        lst.Add(r.GetString(0));
                    }
                }
            }

            SqliteTransaction tran = ActiveConnection.BeginTransaction();
            try
            {
                foreach (String tableName in lst)
                {
                    using (var cmd = new SqliteCommand(String.Format("DELETE FROM __{0}", tableName), tran.Connection, tran))
                        cmd.ExecuteNonQuery();
                }
                using (var cmd = new SqliteCommand(String.Format("DELETE FROM {0}", TranStatusTable), tran.Connection, tran))
                    cmd.ExecuteNonQuery();

                tran.Commit();
            }
            catch
            {
                tran.Rollback();
                throw;
            }
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:33,代码来源:DatabaseTransaction.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Sqlite.SqliteConnection类代码示例发布时间:2022-05-26
下一篇:
C# SymbolWriter.SourceMethodBuilder类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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