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

C# SqliteClient.SqliteCommand类代码示例

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

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



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

示例1: IGADatabaseConnector

        /// <summary>
        /// Creates a new connection to the icontent.cache file.
        /// </summary>
        /// <param name="filename">The file to connect to.</param>
        public IGADatabaseConnector(String filename)
        {
            try {
                sqlite = new SqliteConnection("URI=file:" + filename + ",version=3");
                sqlite.Open();

                SqliteCommand query = new SqliteCommand("SELECT [appId] FROM [contentlist] LIMIT 1", sqlite);
                Object result = query.ExecuteScalar();
                sqlite.Close();
                if (result == null)
                {
                    this._appID = 0;
                }
                else
                {
                    this._appID = (int)result;
                }

                if (this._appID > 0) {
                    this._appSupported = Common.AppInfos.ContainsKey(this._appID);
                } else {
                    this._appSupported = false;
                }

                if (this._appSupported)
                {
                    _appInfo = Common.AppInfos[this._appID];
                }

            } catch (Exception) {
                throw new DatabaseConnectionFailureException();
            }
        }
开发者ID:micolous,项目名称:igaeditor,代码行数:37,代码来源:IGADatabaseConnector.cs


示例2: ExecuteReader

        protected IDataReader ExecuteReader(SqliteCommand cmd)
        {
            SqliteConnection newConnection =
                    (SqliteConnection)((ICloneable)m_Connection).Clone();
            newConnection.Open();

            cmd.Connection = newConnection;
            return cmd.ExecuteReader();
        }
开发者ID:AlphaStaxLLC,项目名称:taiga,代码行数:9,代码来源:SQLiteFramework.cs


示例3: ExecuteNonQuery

        //////////////////////////////////////////////////////////////
        //
        // All non queries are funneled through one connection
        // to increase performance a little
        //
        protected int ExecuteNonQuery(SqliteCommand cmd)
        {
            lock (m_Connection)
            {
                cmd.Connection = m_Connection;

                return cmd.ExecuteNonQuery();
            }
        }
开发者ID:AlphaStaxLLC,项目名称:taiga,代码行数:14,代码来源:SQLiteFramework.cs


示例4: CreateCommand

 // Create SQL Command With Param
 public SqliteCommand CreateCommand(string sql, Hashtable sqlParams)
 {
     SqliteCommand sqlCmd = new SqliteCommand(sql, this);
     if (sqlParams != null) {
         foreach (string key in sqlParams.Keys)
             sqlCmd.Parameters.Add(key, sqlParams[key]);
     }
     return(sqlCmd);
 }
开发者ID:BackupTheBerlios,项目名称:niry-sharp-svn,代码行数:10,代码来源:SQLite.cs


示例5: WrongSyntax

		public void WrongSyntax()
		{
			SqliteCommand insertCmd = new SqliteCommand("INSERT INTO t1 VALUES (,')",_conn);
			using(_conn)
			{
				_conn.Open();
				int res = insertCmd.ExecuteNonQuery();
				Assert.AreEqual(res,1);
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:10,代码来源:SqliteExceptionUnitTests.cs


示例6: InsertRandomValuesWithParameter

		public void InsertRandomValuesWithParameter()
		{
			SqliteParameter textP = new SqliteParameter();
			textP.ParameterName = "textP";
			textP.SourceColumn = "t";
		
			SqliteParameter floatP = new SqliteParameter();
			floatP.ParameterName = "floatP";
			floatP.SourceColumn = "nu";
		
			SqliteParameter integerP = new SqliteParameter();
			integerP.ParameterName ="integerP";
			integerP.SourceColumn = "i";

			SqliteParameter blobP = new SqliteParameter();
			blobP.ParameterName = "blobP";
			blobP.SourceColumn = "b";

			Random random = new Random();
			StringBuilder builder = new StringBuilder();
			for (int k=0; k < random.Next(0,100); k++)
			{
				builder.Append((char)random.Next(65536));
			}
			
			SqliteCommand insertCmd = new SqliteCommand("DELETE FROM t1; INSERT INTO t1  (t, f, i, b ) VALUES(:textP,:floatP,:integerP,:blobP)",_conn);
			
			insertCmd.Parameters.Add(textP);
			insertCmd.Parameters.Add(floatP);
			insertCmd.Parameters.Add(blobP);
			insertCmd.Parameters.Add(integerP);
			
			textP.Value=builder.ToString();
			floatP.Value=Convert.ToInt64(random.Next(999));
			integerP.Value=random.Next(999);
			blobP.Value=System.Text.Encoding.UTF8.GetBytes("\u05D0\u05D1\u05D2" + builder.ToString());
			
			SqliteCommand selectCmd = new SqliteCommand("SELECT * from t1", _conn);

			using(_conn)
			{
				_conn.Open();
				int res = insertCmd.ExecuteNonQuery();
				Assert.AreEqual(res,1);
				
				using (IDataReader reader = selectCmd.ExecuteReader()) {
					Assert.AreEqual(reader.Read(), true);
					Assert.AreEqual(reader["t"], textP.Value);
					Assert.AreEqual(reader["f"], floatP.Value);
					Assert.AreEqual(reader["i"], integerP.Value);
					Assert.AreEqual(reader["b"], blobP.Value);
					Assert.AreEqual(reader.Read(), false);
				}
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:55,代码来源:SqliteParameterUnitTests.cs


示例7: ExecuteNonQuery

 public new void ExecuteNonQuery(string sql, string connectionString)
 {
     using (SqliteConnection conn = new SqliteConnection(connectionString))
     {
         SqliteCommand cmd = new SqliteCommand(sql, conn);
         cmd.CommandTimeout = 1200;
         conn.Open();
         cmd.ExecuteNonQuery();
         conn.Close();
     }
 }
开发者ID:EntropyZero,项目名称:deltaRunner,代码行数:11,代码来源:SqliteTestFixtureBase.cs


示例8: ExecuteScalar

 public new object ExecuteScalar(string sql, string connectionString)
 {
     using (SqliteConnection conn = new SqliteConnection(connectionString))
     {
         SqliteCommand cmd = new SqliteCommand(sql, conn);
         cmd.CommandTimeout = 1200;
         conn.Open();
         object retVal = cmd.ExecuteScalar();
         conn.Close();
         return retVal;
     }
 }
开发者ID:EntropyZero,项目名称:deltaRunner,代码行数:12,代码来源:SqliteTestFixtureBase.cs


示例9: SqliteDataReader

		internal SqliteDataReader (SqliteCommand cmd, IntPtr pVm, int version)
		{
			command = cmd;
			rows = new ArrayList ();
			columns = new ArrayList ();
			column_names = new Hashtable ();
			closed = false;
			current_row = -1;
			reading = true;
			ReadpVm (pVm, version);
			ReadingDone ();
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:12,代码来源:SqliteDataReader.cs


示例10: Convert

        public bool Convert()
        {
            try
            {
                SqliteConnection conn = new SqliteConnection(m_connectionString);
                conn.Open();

                Assembly assem = GetType().Assembly;
                Migration m = new Migration(conn, assem, "RegionStore");

                int version = m.Version;

                if (version <= 14)
                {
                    if (version == 0)
                    {
                        //read rex tables and add to rex database
                        m_log.Info("[regionstore] converting rex tables to rexobjectproperties");
                        if (!ConvertLegacyRexDataToModreX())
                        {
                            conn.Close();
                            return false;
                        }

                        m_log.Info("[RegionStore] Update region migrations");
                        //Add new field to Land table
                        SqliteCommand addAuthbyerIDCmd = new SqliteCommand(addAuthbyerID, conn);
                        addAuthbyerIDCmd.ExecuteNonQuery();

                        //Change migration to version 1
                        m.Version = 1;
                    }

                    //Run migrations up to 9
                    //Note: this run migrations only to point nine since only those files exist in application resources.
                    m.Update();

                    //Skip over 10. Change version to 10
                    //This skips adding of the ClickAction since that already exists in 0.4 database
                    //m.Version = 10;
                }

                conn.Close();
                return true;
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[RegionStore] Migration failed. Reason: {0}", e);
                return false;
            }
        }
开发者ID:mattire,项目名称:ModreX,代码行数:51,代码来源:RegionMigration.cs


示例11: Get

        public AuthenticationData Get(UUID principalID)
        {
            AuthenticationData ret = new AuthenticationData();
            ret.Data = new Dictionary<string, object>();

            SqliteCommand cmd = new SqliteCommand("select * from `" + m_Realm + "` where UUID = :PrincipalID");
            cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString()));

            IDataReader result = ExecuteReader(cmd, m_Connection);

            try
            {
                if (result.Read())
                {
                    ret.PrincipalID = principalID;

                    if (m_ColumnNames == null)
                    {
                        m_ColumnNames = new List<string>();

                        DataTable schemaTable = result.GetSchemaTable();
                        foreach (DataRow row in schemaTable.Rows)
                            m_ColumnNames.Add(row["ColumnName"].ToString());
                    }

                    foreach (string s in m_ColumnNames)
                    {
                        if (s == "UUID")
                            continue;

                        ret.Data[s] = result[s].ToString();
                    }

                    return ret;
                }
                else
                {
                    return null;
                }
            }
            catch
            {
            }
            finally
            {
                CloseCommand(cmd);
            }

            return null;
        }
开发者ID:dreamerc,项目名称:diva-distribution,代码行数:50,代码来源:SQLiteAuthenticationData.cs


示例12: ExecuteReader

        protected IDataReader ExecuteReader(SqliteCommand cmd, SqliteConnection connection)
        {
            lock (connection)
            {
                SqliteConnection newConnection =
                        (SqliteConnection)((ICloneable)connection).Clone();
                newConnection.Open();

                cmd.Connection = newConnection;
                //Console.WriteLine("XXX " + cmd.CommandText);

                return cmd.ExecuteReader();
            }
        }
开发者ID:dreamerc,项目名称:diva-distribution,代码行数:14,代码来源:SQLiteFramework.cs


示例13: SqliteDataReader

		internal SqliteDataReader (SqliteCommand cmd, IntPtr pVm, int version)
		{
			command = cmd;
			rows = new ArrayList ();
			column_names_sens = new Hashtable ();
#if NET_2_0
			column_names_insens = new Hashtable (StringComparer.InvariantCultureIgnoreCase);
#else
			column_names_insens = new Hashtable (CaseInsensitiveHashCodeProvider.DefaultInvariant,
							     CaseInsensitiveComparer.DefaultInvariant);
#endif
			closed = false;
			current_row = -1;
			reading = true;
			ReadpVm (pVm, version, cmd);
			ReadingDone ();
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:17,代码来源:SqliteDataReader.cs


示例14: PrepareDataAdapter

		static SqliteDataAdapter PrepareDataAdapter()
		{
			SqliteCommand select  = new SqliteCommand("SELECT t, f, i, b FROM t1",_conn);
			SqliteCommand update = new SqliteCommand("UPDATE t1 SET t = :textP, f = :floatP, i = :integerP, n=:blobP WHERE t = :textP ");
			update.Connection=_conn;
			SqliteCommand delete = new SqliteCommand("DELETE FROM t1 WHERE t = :textP");
			delete.Connection=_conn;
			SqliteCommand insert = new SqliteCommand("INSERT INTO t1  (t, f, i, b ) VALUES(:textP,:floatP,:integerP,:blobP)");
			insert.Connection=_conn;
			SqliteDataAdapter custDA = new SqliteDataAdapter(select);
		
			SqliteParameter textP = new SqliteParameter();
			textP.ParameterName = "textP";
			textP.SourceColumn = "t";
		
			SqliteParameter floatP = new SqliteParameter();
			floatP.ParameterName = "floatP";
			floatP.SourceColumn = "f";
		
			SqliteParameter integerP = new SqliteParameter();
			integerP.ParameterName ="integerP";
			integerP.SourceColumn = "i";

			SqliteParameter blobP = new SqliteParameter();
			blobP.ParameterName = "blobP";
			blobP.SourceColumn = "b";
		
			update.Parameters.Add(textP);
			update.Parameters.Add(floatP);
			update.Parameters.Add(integerP);
			update.Parameters.Add(blobP);
		
			delete.Parameters.Add(textP);
		
			insert.Parameters.Add(textP);
			insert.Parameters.Add(floatP);
			insert.Parameters.Add(integerP);
			insert.Parameters.Add(blobP);
		
			custDA.UpdateCommand = update;
			custDA.DeleteCommand = delete;
			custDA.InsertCommand = insert;
		
			return custDA;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:45,代码来源:SqliteDataAdapterUnitTests.cs


示例15: Select

		public void Select()
		{
			SqliteCommand simpleSelect = new SqliteCommand("SELECT * FROM t1;  ", _conn); // check trailing spaces
			using(_conn)
			{
				_conn.Open();
				SqliteDataReader dr = simpleSelect.ExecuteReader();
				while(dr.Read())
				{
					string test = dr[0].ToString();
					Assert.AreEqual(dr["T"], stringvalue); // also checks case-insensitive column
					Assert.AreEqual(dr["F"], 123);
					Assert.AreEqual(dr["I"], 123);
					Assert.AreEqual(dr["B"], "123");
				}
				Assert.IsTrue(dr.FieldCount>0);
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:18,代码来源:SqliteCommandUnitTests.cs


示例16: Convert

        public bool Convert()
        {
            try
            {
                SqliteConnection conn = new SqliteConnection(m_connectionString);
                conn.Open();

                Assembly assem = GetType().Assembly;
                Migration m = new Migration(conn, assem, "InventoryStore");
                if (m.Version == 0)
                {
                    //Apply all changes to db
                    SqliteCommand addSalePriceCmd = new SqliteCommand(addSalePrice, conn);
                    addSalePriceCmd.ExecuteNonQuery();

                    SqliteCommand addSaleTypeCmd = new SqliteCommand(addSaleType, conn);
                    addSaleTypeCmd.ExecuteNonQuery();

                    SqliteCommand addCreationDateCmd = new SqliteCommand(addCreationDate, conn);
                    addCreationDateCmd.ExecuteNonQuery();

                    SqliteCommand addGroupIDCmd = new SqliteCommand(addGroupID, conn);
                    addGroupIDCmd.ExecuteNonQuery();

                    SqliteCommand addGroupOwnedCmd = new SqliteCommand(addGroupOwned, conn);
                    addGroupOwnedCmd.ExecuteNonQuery();

                    SqliteCommand addFlagsCmd = new SqliteCommand(addFlags, conn);
                    addFlagsCmd.ExecuteNonQuery();

                    //then change version number
                    m.Version = 1;
                }
                return true;
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[InventoryStore] Migration failed. Reason: {0}", e);
                return false;
            }
        }
开发者ID:jonnenauha,项目名称:ModreX,代码行数:41,代码来源:InventoryMigration.cs


示例17: Get

        public string Get(string scope, string key)
        {
            string command = "SELECT `value` FROM `generic` WHERE `key` = @key";
            if (!String.IsNullOrEmpty(scope))
                command += " AND `scope` = @scope";

            lock (this)
            {
                using (SqliteCommand cmd = new SqliteCommand(command, m_Connection))
                {
                    cmd.Parameters.Add("@key", key);
                    if (!String.IsNullOrEmpty(scope))
                        cmd.Parameters.Add("@scope", scope);

                    using (IDataReader result = cmd.ExecuteReader())
                    {
                        if (result.Read())
                            return result.GetString(0);
                        else
                            return null;
                    }
                }
            }
        }
开发者ID:AlphaStaxLLC,项目名称:taiga,代码行数:24,代码来源:SQLiteGenericData.cs


示例18: Create

		public void Create()
		{
			try
			{
				if(File.Exists(_uri))
				{
					_conn.Dispose();
					// We want to start with a fresh db for each full run
					// The database is created on the first open()
					File.Delete(_uri);
					_conn = new SqliteConnection (_connectionString);
				}
			}
			catch(Exception e)
			{
				throw e;
			}
			
			SqliteCommand createCommand = new SqliteCommand("CREATE TABLE t1(t  TEXT,  f FLOAT, i INTEGER, b TEXT);",_conn);
			SqliteCommand insertCommand = new SqliteCommand("INSERT INTO t1  (t, f, i, b ) VALUES('" + stringvalue + "',123,123,'123')",_conn);

			try
			{
				_conn.Open();
				createCommand.ExecuteNonQuery();
				insertCommand.ExecuteNonQuery();
			}
			catch(Exception e)
			{
				throw new AssertionException("Create table failed",e);
			}
			finally
			{
				_conn.Close();  
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:36,代码来源:SqliteCommandUnitTests.cs


示例19: Initialise

        /// <summary>
        /// <list type="bullet">
        /// <item>Initialises Inventory interface</item>
        /// <item>Loads and initialises a new SQLite connection and maintains it.</item>
        /// <item>use default URI if connect string string is empty.</item>
        /// </list>
        /// </summary>
        /// <param name="dbconnect">connect string</param>
        public void Initialise(string dbconnect)
        {
            if (dbconnect == string.Empty)
            {
                dbconnect = "URI=file:inventoryStore.db,version=3";
            }
            m_log.Info("[INVENTORY DB]: Sqlite - connecting: " + dbconnect);
            conn = new SqliteConnection(dbconnect);

            conn.Open();

            Assembly assem = GetType().Assembly;
            Migration m = new Migration(conn, assem, "InventoryStore");
            m.Update();

            SqliteCommand itemsSelectCmd = new SqliteCommand(invItemsSelect, conn);
            invItemsDa = new SqliteDataAdapter(itemsSelectCmd);
            //            SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa);

            SqliteCommand foldersSelectCmd = new SqliteCommand(invFoldersSelect, conn);
            invFoldersDa = new SqliteDataAdapter(foldersSelectCmd);

            ds = new DataSet();

            ds.Tables.Add(createInventoryFoldersTable());
            invFoldersDa.Fill(ds.Tables["inventoryfolders"]);
            setupFoldersCommands(invFoldersDa, conn);
            m_log.Info("[INVENTORY DB]: Populated Inventory Folders Definitions");

            ds.Tables.Add(createInventoryItemsTable());
            invItemsDa.Fill(ds.Tables["inventoryitems"]);
            setupItemsCommands(invItemsDa, conn);
            m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions");

            ds.AcceptChanges();
        }
开发者ID:AlphaStaxLLC,项目名称:taiga,代码行数:44,代码来源:SQLiteInventoryStore.cs


示例20: rep_DefaultReport_data

        public stats_default_page_values rep_DefaultReport_data(SqliteConnection db, List<Scene> m_scene)
        {
            stats_default_page_values returnstruct = new stats_default_page_values();
            returnstruct.all_scenes = m_scene.ToArray();
            lock (db)
            {
                string SQL = @"SELECT COUNT(DISTINCT agent_id) as agents, COUNT(*) as sessions, AVG(avg_fps) as client_fps, 
                                AVG(avg_sim_fps) as savg_sim_fps, AVG(avg_ping) as sav_ping, SUM(n_out_kb) as num_in_kb, 
                                SUM(n_out_pk) as num_in_packets, SUM(n_in_kb) as num_out_kb, SUM(n_in_pk) as num_out_packets, AVG(mem_use) as sav_mem_use
                                FROM stats_session_data;";
                SqliteCommand cmd = new SqliteCommand(SQL, db);
                SqliteDataReader sdr = cmd.ExecuteReader();
                if (sdr.HasRows)
                {
                    sdr.Read();
                    returnstruct.total_num_users = Convert.ToInt32(sdr["agents"]);
                    returnstruct.total_num_sessions = Convert.ToInt32(sdr["sessions"]);
                    returnstruct.avg_client_fps = Convert.ToSingle(sdr["client_fps"]);
                    returnstruct.avg_sim_fps = Convert.ToSingle(sdr["savg_sim_fps"]);
                    returnstruct.avg_ping = Convert.ToSingle(sdr["sav_ping"]);
                    returnstruct.total_kb_out = Convert.ToSingle(sdr["num_out_kb"]);
                    returnstruct.total_kb_in = Convert.ToSingle(sdr["num_in_kb"]);
                    returnstruct.avg_client_mem_use = Convert.ToSingle(sdr["sav_mem_use"]);

                }
            }
            return returnstruct;
        }
开发者ID:p07r0457,项目名称:opensim,代码行数:28,代码来源:Default_Report.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# SqliteClient.SqliteConnection类代码示例发布时间:2022-05-26
下一篇:
C# Tests.OrmTestSession类代码示例发布时间: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