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


C# System.Data.SQLite.SQLiteConnection.CreateCommand方法代码示例

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


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

示例1: TestCaseSensitiveKeyColumn

        public void TestCaseSensitiveKeyColumn()
        {
            var path = Path.GetTempFileName();
            try
            {
                var sqlite = new System.Data.SQLite.SQLiteConnection("Data Source=" + path);
                sqlite.Open();
                var cmd = sqlite.CreateCommand();
                cmd.CommandText = "create table test(col_ID integer primary key, name text, shape blob)";
                cmd.ExecuteNonQuery();
                cmd.Dispose();
                sqlite.Close();
                sqlite.Dispose();
                using (var sq = new ManagedSpatiaLite("Data Source=" + path, "test", "shape", "COL_ID"))
                {
                    var ext = new Envelope();
                    var ds = new SharpMap.Data.FeatureDataSet();
                    sq.ExecuteIntersectionQuery(ext, ds);
                    NUnit.Framework.Assert.AreEqual(0, ds.Tables[0].Count);
                }

            }
            catch (Exception ex)
            {
                Assert.Fail("Got exception, should not happen");

            }
            finally
            {
                File.Delete(path);
            }
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:32,代码来源:ManagedSQLiteTests.cs

示例2: FindOpcodes

        public static void FindOpcodes(string query)
        {
            var files = System.IO.Directory.GetFiles(@"E:\HFS\WOWDEV\SNIFFS_CLEAN\", "*.sqlite", System.IO.SearchOption.AllDirectories).OrderByDescending(t => t);

            foreach (var file in files)
            {
                using (var con = new System.Data.SQLite.SQLiteConnection("Data Source=" + file))
                {
                    con.Open();
                    using (var sqlcommand = con.CreateCommand())
                    {
                        sqlcommand.CommandText = "select count(*) from packets where opcode in (" + query + ")";
                        var reader = sqlcommand.ExecuteReader();

                        while (reader.Read())
                        {
                            var found = reader.GetInt32(0);
                            if (found > 0)
                            {
                                System.Diagnostics.Debug.WriteLine(file + "\t" + found);
                            }
                            break;
                        }
                    }

                    con.Close();
                }
            }
        }
开发者ID:RaptorFactor,项目名称:devmaximus,代码行数:29,代码来源:CustomFindOpcode.cs

示例3: DumpOpcodes

        public static void DumpOpcodes()
        {
            var files = System.IO.Directory.GetFiles(@"E:\HFS\WOWDEV\SNIFFS_CLEAN\", "*.sqlite", System.IO.SearchOption.AllDirectories).OrderBy(t => t);

            var versionOpcodeList = new System.Collections.Generic.SortedList<uint, ClientBuildCache>();

            foreach (var file in files)
            {
                uint clientBuild = 0;

                using (var con = new System.Data.SQLite.SQLiteConnection("Data Source=" + file))
                {
                    con.Open();
                    using (var sqlcommand = con.CreateCommand())
                    {
                        sqlcommand.CommandText = "select key, value from header where key = 'clientBuild'";
                        var reader = sqlcommand.ExecuteReader();

                        while (reader.Read())
                        {
                            clientBuild = (uint)reader.GetInt32(1);
                            break;
                        }
                    }

                    if (!versionOpcodeList.ContainsKey(clientBuild))
                    {
                        versionOpcodeList.Add(clientBuild, new ClientBuildCache() { ClientBuild = clientBuild, OpcodeList = new List<OpcodeCache>() });
                    }

                    var clientBuildOpcodes = versionOpcodeList[clientBuild];

                    using (var sqlcommand = con.CreateCommand())
                    {
                        sqlcommand.CommandText = "select distinct opcode, direction from packets order by opcode , direction";
                        var reader = sqlcommand.ExecuteReader();

                        while (reader.Read())
                        {
                            var opcode = (uint)reader.GetInt32(0);
                            var direction = (byte)reader.GetInt32(1);

                            if (!clientBuildOpcodes.OpcodeList.Exists(t => t.Opcode == opcode && t.Direction == direction))
                                clientBuildOpcodes.OpcodeList.Add(new OpcodeCache() { Direction = direction, Opcode = opcode });
                        }
                    }

                    con.Close();
                }
            }

            var clientBuildOpcodeList = versionOpcodeList.Select(t => t.Value).ToList();

            clientBuildOpcodeList.SaveObject("clientBuildOpcodeList.xml");
        }
开发者ID:RaptorFactor,项目名称:devmaximus,代码行数:55,代码来源:CustomDumpOpcode.cs

示例4: ExecAsync

		public async Task<int> ExecAsync(SQLiteConnection conn)
		{
			var sql = GetQueryString();
			if (!sql.Any()) return 0; 
			#if DEBUG
			Console.WriteLine(sql + System.Environment.NewLine);
			#endif
			using(var cmd = conn.CreateCommand())
			{
				SetQuery(cmd);
				return await cmd.ExecuteNonQueryAsync();
			}
		}
开发者ID:naokirin,项目名称:Buffet,代码行数:13,代码来源:NonQeuryCommand.cs

示例5: AddNewClass

 public void AddNewClass(ClassModel clazz)
 {
     using (var connection = new System.Data.SQLite.SQLiteConnection(this.connString))
     {
         connection.Open();
         using (var cmd = connection.CreateCommand())
         {
             cmd.CommandText = "INSERT INTO Classes (ClassId, ClassName) VALUES(@Id, @Name)";
             cmd.Parameters.AddWithValue("@Id", clazz.Id);
             cmd.Parameters.AddWithValue("@Name", clazz.Name);
             cmd.ExecuteNonQuery();
         }
     }
 }
开发者ID:damsaneta,项目名称:LibrusWP,代码行数:14,代码来源:DatabaseTests.cs

示例6: CreateCacheManagementDBIfNotExists

        public void CreateCacheManagementDBIfNotExists()
        {
            var dbFilePath = Path.Combine(_root, "cache_mgr.db");

            if(!File.Exists(dbFilePath))
            {
                using (var connection = new System.Data.SQLite.SQLiteConnection("Data Source=" + dbFilePath + ";Version=3;"))
                {
                    var createTableCmd = connection.CreateCommand();

                    createTableCmd.CommandText = "";
                }
            }
        }
开发者ID:dream-365,项目名称:toolkit,代码行数:14,代码来源:CacheManagement.cs

示例7: AddNewStudent

        //uzytkownicy
        public void AddNewStudent(StudentModel user)
        {
            var student = user as StudentModel;
            using (var connection = new System.Data.SQLite.SQLiteConnection(this.connString))
            {
                connection.Open();
                using (var cmd = connection.CreateCommand())
                {
                    cmd.CommandText = @"INSERT INTO Students (Name, Surname, Gender, ClassId)
                        VALUES (@name, @surname, @gender, @classId)";
                    cmd.Parameters.AddWithValue("@name", user.Name);
                    cmd.Parameters.AddWithValue("@surname", user.Surname);
                    int gen = (user.Gender)? 1 : 0;
                    cmd.Parameters.AddWithValue("@gender", gen);
                    cmd.Parameters.AddWithValue("@classId", student != null ? (object)student.Class.Id : DBNull.Value);
                    cmd.ExecuteNonQuery();

                }
            }
        }
开发者ID:damsaneta,项目名称:LibrusWP,代码行数:21,代码来源:DatabaseTests.cs

示例8: MainForm

        public MainForm()
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            RssCache = new List<RssCacheItem>();

            try {
                this.AppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                if (!System.IO.Directory.Exists(this.AppDataPath + "\\BmReader")){
                    System.IO.Directory.CreateDirectory(this.AppDataPath + "\\BmReader");
                }
                this.AppDataPath += "\\BmReader";

                if (!System.IO.File.Exists(this.AppDataPath + "\\data.db")){
                    //System.Data.SQLite.SQLiteConnection.CreateFile(this.AppDataPath + "\\data.db");
                }

                conn =
                    new System.Data.SQLite.SQLiteConnection(String.Format("Data Source={0};Version=3;", this.AppDataPath + "\\data.db"));

                conn.Open();
                if(conn.GetSchema("Tables",new string[]{null, null, "URLRSS", null}).Rows.Count == 0){
                    System.Data.SQLite.SQLiteCommand cmd = conn.CreateCommand();
                    cmd.CommandText = "CREATE TABLE URLRSS (id integer primary key, Url CHAR(1000), active Boolean true)";
                    cmd.ExecuteNonQuery();
                }

                System.Data.SQLite.SQLiteDataAdapter da = new System.Data.SQLite.SQLiteDataAdapter("select * from urlrss", conn);
                System.Data.SQLite.SQLiteCommandBuilder cb = new System.Data.SQLite.SQLiteCommandBuilder(da);

                LoadFeeds();

            } catch (Exception err){
                MessageBox.Show(err.Message);
                Application.Exit();
            }
        }
开发者ID:binamonk,项目名称:DotNetRssReader,代码行数:40,代码来源:MainForm.cs

示例9: AddNewSubject

 //repozytorium klas
 public void AddNewSubject(SubjectModel subject)
 {
     using (var connection = new System.Data.SQLite.SQLiteConnection(this.connString))
     {
         connection.Open();
         using (var cmd = connection.CreateCommand())
         {
             cmd.CommandText = "INSERT INTO Subjects (SubjectId, SubjectName) VALUES(@Id, @Name)";
             cmd.Parameters.AddWithValue("@Id", subject.Id);
             cmd.Parameters.AddWithValue("@Name", subject.Name);
             cmd.ExecuteNonQuery();
         }
     }
 }
开发者ID:damsaneta,项目名称:LibrusWP,代码行数:15,代码来源:DatabaseTests.cs

示例10: GetClassById

        public ClassModel GetClassById(string id)
        {
            ClassModel clazz = null;
            using (var connection = new System.Data.SQLite.SQLiteConnection(this.connString))
            {
                connection.Open();
                using (var cmd = connection.CreateCommand())
                {
                    cmd.CommandText = "SELECT * FROM Classes WHERE ClassId = @Id";
                    cmd.Parameters.AddWithValue("@Id", id);
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var idd = reader["ClassId"].ToString();
                            clazz = new ClassModel(idd);
                        }

                    }

                }

            }
            return clazz;
        }
开发者ID:damsaneta,项目名称:LibrusWP,代码行数:25,代码来源:DatabaseTests.cs

示例11: Test2

    private static void Test2(string connString)
    {
      Console.WriteLine("Begin Test2");
 
      using (var dbConn = new System.Data.SQLite.SQLiteConnection(connString))
      {
        dbConn.Open();
        using (System.Data.SQLite.SQLiteCommand cmd = dbConn.CreateCommand())
        {
          //create table
          cmd.CommandText = @"CREATE TABLE IF NOT EXISTS T1 (ID integer primary key, T text);";
          cmd.ExecuteNonQuery();
 
          //parameterized insert - more flexibility on parameter creation
          cmd.CommandText = @"INSERT INTO T1 (ID,T) VALUES(@id,@t)";
 
          cmd.Parameters.Add(new System.Data.SQLite.SQLiteParameter 
            { 
              ParameterName = "@id", 
              Value = 1 
            });
 
          cmd.Parameters.Add(new System.Data.SQLite.SQLiteParameter
          {
            ParameterName = "@t",
            Value = "test2"
          });
 
          cmd.ExecuteNonQuery();
 
          //read from the table
          cmd.CommandText = @"SELECT ID, T FROM T1";
          using (System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader())
          {
            while (reader.Read())
            {
              long id = reader.GetInt64(0);
              string t = reader.GetString(1);
              Console.WriteLine("record read as id: {0} t: {1}", id, t);
            }
          }
        }
        if (dbConn.State != System.Data.ConnectionState.Closed) dbConn.Close();
      }
      Console.WriteLine("End Test2");
    }
开发者ID:Jarolim,项目名称:AllMyHomeworkForTelerikAcademy,代码行数:46,代码来源:Class1.cs

示例12: btnConsultar_Click

        private void btnConsultar_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                DicCompileExample = new Dictionary<string, Func<CompilerWithFuzzy.Compiler.Syn.ParseTree.Container, string>>();

                DicCompileExample.Add("Tabela", c => string.Format("{0}", c["nometabela"].Value));

                DicCompileExample.Add("Campo", CompilarCampo);

                DicCompileExample.Add("Initial", CompilarInitial);

                DicCompileExample.Add("Condicao", Condicao);

                cxp.Compiler.DicCompile = DicCompileExample;

                try
                {
                    cxp.Compiler.Compile(richTextConsulta.Text);

                    if (!string.IsNullOrEmpty(cxp.Compiler.CodeCompiled))
                    {
                        linkLabel.Text = "Correto: " + cxp.Compiler.CodeModifySource;

                        if (cxp.Compiler.CodeModifySource.ToLower() != richTextConsulta.Text.ToLower())
                        {
                            linkLabel.Visible = true;
                        }
                        else
                        {
                            linkLabel.Visible = false;
                        }

                        try
                        {
                            using (System.Data.SQLite.SQLiteConnection sql = new System.Data.SQLite.SQLiteConnection("data source=Banco; Version=3;"))
                            {
                                sql.Open();
                                using (var command = sql.CreateCommand())
                                {
                                    command.CommandText = cxp.Compiler.CodeCompiled;
                                    using (var reader = command.ExecuteReader())
                                    {
                                        DataTable dt = new DataTable();
                                        dt.Load(reader);

                                        dgvResultado.DataSource = dt;
                                        dgvResultado.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;

                                        lblMensagem.Text = "Consulta realizada com sucesso!";
                                        lblMensagem.ForeColor = Color.Green;
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            lblMensagem.Text = "Erro ao executar consulta! Msg: " + ex.ToString();
                            lblMensagem.ForeColor = Color.Red;
                        }
                    }
                    else
                    {
                        lblMensagem.Text = "Verifique sua consulta!";
                        lblMensagem.ForeColor = Color.Red;
                    }
                }
                catch (Exception ex)
                {
                    lblMensagem.Text = "Verifique sua consulta!";
                    lblMensagem.ForeColor = Color.Red;
                }
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
开发者ID:rodvieirasilva,项目名称:Compiler-With-Fuzzy,代码行数:80,代码来源:FormQueryExample.cs

示例13: GetStudentsByClass

        IList<StudentModel> GetStudentsByClass(string id)
        {
            IList<StudentModel> list = new List<StudentModel>();
             using (var connection = new System.Data.SQLite.SQLiteConnection(this.connString))
             {
                 connection.Open();
                 using (var cmd = connection.CreateCommand())
                 {
                     cmd.CommandText = @"SELECT * FROM Students WHERE ClassId = @id";
                     cmd.Parameters.AddWithValue("@id", id);
                     using (var reader = cmd.ExecuteReader())
                     {
                         while (reader.Read())
                         {
                             var surname = reader["Surname"].ToString();
                             var name = reader["Name"].ToString();
                             var gen = reader["Gender"];
                             bool gender = Convert.ToBoolean(gen);
                             var classId = reader["ClassId"] == DBNull.Value ? null : (object)reader["ClassId"].ToString();
                             ClassModel clazz = this.GetClassById(classId.ToString());
                             var user = new StudentModel(name, surname, clazz, gender);
                             list.Add(user);
                         }
                     }

                 }
             }
             return list;
        }
开发者ID:damsaneta,项目名称:LibrusWP,代码行数:29,代码来源:DatabaseTests.cs

示例14: GetTimeTableById

        TimeTableModel GetTimeTableById(int timetableId)
        {
            TimeTableModel timeTable = null;
             using (var connection = new System.Data.SQLite.SQLiteConnection(this.connString))
             {
                 connection.Open();
                 using (var cmd = connection.CreateCommand())
                 {
                     cmd.CommandText = @"SELECT * FROM TimeTables WHERE Id [email protected]";
                     cmd.Parameters.AddWithValue("@id", timetableId);
                     using (var reader = cmd.ExecuteReader())
                     {
                         while (reader.Read())
                         {
                             int id = Convert.ToInt32(reader["Id"]);
                             string day = reader["Day"].ToString();
                             var classId = reader["ClassId"] == DBNull.Value ? null : (object)reader["ClassId"].ToString();
                             var subjectId = reader["SubjectId"] == DBNull.Value ? null : (object)reader["SubjectId"].ToString();
                             ClassModel clazzz = this.GetClassById(classId.ToString());
                             SubjectModel sub = this.GetSubjectById(subjectId.ToString());
                             timeTable = new TimeTableModel(id, day, clazzz, sub);
                         }
                     }

                 }
             }
             return timeTable;
        }
开发者ID:damsaneta,项目名称:LibrusWP,代码行数:28,代码来源:DatabaseTests.cs

示例15: GetAllTimeTable

        IList<TimeTableModel> GetAllTimeTable()
        {
            IList<TimeTableModel> timeTable = new List<TimeTableModel>();
            using (var connection = new System.Data.SQLite.SQLiteConnection(this.connString))
            {
                connection.Open();
                using (var cmd = connection.CreateCommand())
                {
                    cmd.CommandText = @"SELECT * FROM TimeTables";
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            int id = Convert.ToInt32(reader["Id"]);
                            string day = reader["Day"].ToString();
                            var classId = reader["ClassId"] == DBNull.Value ? null : (object)reader["ClassId"].ToString();
                            var subjectId = reader["SubjectId"] == DBNull.Value ? null : (object)reader["SubjectId"].ToString();
                            ClassModel clazzz = this.GetClassById(classId.ToString());
                            SubjectModel sub = this.GetSubjectById(subjectId.ToString());
                            var  timetable = new TimeTableModel(id, day, clazzz, sub);
                            timeTable.Add(timetable);
                        }
                    }

                }
            }
            return timeTable;
        }
开发者ID:damsaneta,项目名称:LibrusWP,代码行数:28,代码来源:DatabaseTests.cs


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