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


C# SqliteConnection.CreateCommand方法代码示例

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


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

示例1: Store

    public Store(string fname, string cachedir)
    {
        updates = new ArrayList ();
        newchans = new ArrayList ();
        connection = new SqliteConnection ("URI=file:" + fname);
        connection.Open ();

        IDbCommand dbcmd = connection.CreateCommand ();
        // setting encoding only works on sqlite3
        //dbcmd.CommandText = "PRAGMA encoding = \"UTF-8\";";
        //if (dbcmd.ExecuteNonQuery () != 0) {
        //	throw new Exception ("Couldn't set encoding");
        //}
        string sql = "PRAGMA table_info(channel)";
        dbcmd = connection.CreateCommand ();
        dbcmd.CommandText = sql;
        try {
            IDataReader result = dbcmd.ExecuteReader ();
         			if (!result.Read ()) {
         				// schema doesn't exist.
         				System.Console.WriteLine ("Creating new database schema");
         				CreateSchema ();
            }
            result.Close ();
        } catch (Exception e) {
            // TODO: catch further exceptions here.
            System.Console.WriteLine ("Error executing reader: {0}", e.ToString ());
        }
        _cachedir = cachedir;
        InitializeCache ();
        // TODO: catch problems making the cache dir
    }
开发者ID:BackupTheBerlios,项目名称:monopod-svn,代码行数:32,代码来源:Store.cs

示例2: Start

    // Use this for initialization
    void Start()
    {

        //E:\Etude\Projet\Projet_4e_semestre\GITHUB\New_Unity_Project\Assets


        const string connectionString = "URI=file:E://Etude/Projet/Projet_4e_semestre/GITHUB/New_Unity_Project/Assets/testbdd.s3db";
        IDbConnection dbcon = new SqliteConnection(connectionString);
        IDbCommand dbcmd = dbcon.CreateCommand();
        try
        {
            dbcon.Open();

            const string sql = "select nomcarte from carte";
            dbcmd.CommandText = sql;
            IDataReader reader = dbcmd.ExecuteReader();
            while (reader.Read())
            {
                string NomCarte = reader.GetString(0);
                Debug.Log("Carte: " + NomCarte + "\n");
            }
            reader.Dispose();

        }
        catch (Exception ex)
        {
            Debug.Log(ex.Message);
        }
        dbcmd.Dispose();
        dbcon.Close();

    }
开发者ID:vnigaud,项目名称:Jeu_de_carte,代码行数:33,代码来源:connexion.cs

示例3: Start

    // Use this for initialization
    void Start () {
        const string connectionString = "URI=file:E://Etude/Projet/Projet_4e_semestre/GITHUB/New_Unity_Project/Assets/testbdd.s3db";
        IDbConnection dbcon = new SqliteConnection(connectionString);
        IDbCommand dbcmd = dbcon.CreateCommand();
        try
        {
            dbcon.Open();

            const string sql = "SELECT DISTINCT nomcarte, puisscrea, vitcrea, typecrea, pvcrea, nomatk, dommatk, vitatk FROM carte INNER JOIN creature ON creature.IDCARTE = carte.IDCARTE INNER JOIN j_crea_atk On j_crea_atk.IDCREA = creature.IDCARTE INNER JOIN atk On atk.IDATK = j_crea_atk.IDATK WHERE carte.IDCARTE = '1' AND atk.IDATK='1'";
            dbcmd.CommandText = sql;
            IDataReader reader = dbcmd.ExecuteReader();
            while (reader.Read())
            {
                IDCARTE = reader.GetInt32(0);
            }
            reader.Dispose();

        }
        catch (Exception ex)
        {
            Debug.Log(ex.Message);
        }
        dbcmd.Dispose();
        dbcon.Close();
    }
开发者ID:vnigaud,项目名称:Jeu_de_carte,代码行数:26,代码来源:CreationDeckEnJeu.cs

示例4: init

    public void init(int idcarte, string numserie, int idatk, int idatk2)
    {
        this.idcarte = idcarte;
        this.numserie = numserie;

        xdeck = this.transform.position.x;
        ydeck = this.transform.position.y;
        zdeck = this.transform.position.z;
        ObservJ1 = false;
        ObservJ2 = false;

        mettredsdeck = false;

        const string connectionString = "URI=file:E://Etude/Projet/Projet_4e_semestre/GITHUB/New_Unity_Project/Assets/testbdd.s3db";

        IDbConnection dbcon = new SqliteConnection(connectionString);
        IDbCommand dbcmd = dbcon.CreateCommand();
        try
        {
            dbcon.Open();

            string sql = "SELECT DISTINCT nomcarte, puisscrea, vitcrea, typecrea, pvcrea, nomatk, dommatk, vitatk FROM carte INNER JOIN creature ON creature.IDCARTE = carte.IDCARTE INNER JOIN j_crea_atk On j_crea_atk.IDCREA = creature.IDCARTE INNER JOIN atk On atk.IDATK = j_crea_atk.IDATK WHERE carte.NUMSERIE = '" + this.numserie + "' AND atk.IDATK=" + this.idatk + "";

            dbcmd.CommandText = sql;
            IDataReader reader = dbcmd.ExecuteReader();
            while (reader.Read())
            {
                NomCarte = reader.GetString(0);
                puisscrea = reader.GetInt32(1);
                vitcrea = reader.GetInt32(2);
                typecrea = reader.GetString(3);
                pvcrea = reader.GetInt32(4);
                nomatk = reader.GetString(5);
                dommatk = reader.GetInt32(6);
                vitatk = reader.GetInt32(7);
            }
            reader.Dispose();

            string sql2 = "SELECT DISTINCT nomcarte, puisscrea, vitcrea, typecrea, pvcrea, nomatk, dommatk, vitatk FROM carte INNER JOIN creature ON creature.IDCARTE = carte.IDCARTE INNER JOIN j_crea_atk On j_crea_atk.IDCREA = creature.IDCARTE INNER JOIN atk On atk.IDATK = j_crea_atk.IDATK WHERE carte.NUMSERIE = '" + this.numserie + "' AND atk.IDATK=" + this.idatk2 + "";
            dbcmd.CommandText = sql2;

            IDataReader reader2 = dbcmd.ExecuteReader();
            while (reader2.Read())
            {
                nomatk2 = reader2.GetString(5);
                dommatk2 = reader2.GetInt32(6);
                vitatk2 = reader2.GetInt32(7);
            }
            reader2.Dispose();
        }
        catch (Exception ex)
        {
            Debug.Log(ex.Message);
        }
        dbcmd.Dispose();
        dbcon.Close();

    }
开发者ID:vnigaud,项目名称:Jeu_de_carte,代码行数:58,代码来源:ScriptCarteEffet.cs

示例5: ExecuteSQL

 public static IDataReader ExecuteSQL(string db, string sql)
 {
     var connection = new SqliteConnection(db);
     connection.Open();
     var command = connection.CreateCommand();
     command.CommandText = sql;
     var result = command.ExecuteReader();
     connection.Close();
     return result;
 }
开发者ID:somers353,项目名称:gamedev-group1A,代码行数:10,代码来源:SQLiteConnector.cs

示例6: Database

    public Database(string file)
    {
        bool create = false;
        if (!File.Exists (file)) {
            create = true;
        }

        try {
            StreamReader srVersion = new StreamReader (file+".version");
            dbVersion = srVersion.ReadToEnd ();
            if (dbVersion != null) {
                dbVersion = dbVersion.Trim();
            }
            srVersion.Close();
        }
        catch {
            dbVersion = null;
        }

        string connectionString = "URI=file:"+file;
        connection = new SqliteConnection(connectionString);
        connection.Open();
        command = connection.CreateCommand();

        if (create) {
            Conf.EmptyCache();
            Assembly thisAssembly = Assembly.GetEntryAssembly ();
            Stream stream = thisAssembly.GetManifestResourceStream("Database.sql");
            if (stream != null) {
                StreamReader sr = new StreamReader (stream);
                string sql = sr.ReadToEnd();
                command.CommandText = sql;
                command.ExecuteNonQuery();

                StreamWriter swVersion = new StreamWriter (file+".version", false);
                swVersion.Write (Defines.VERSION);
                swVersion.Close();

                dbVersion = Defines.VERSION;
            }
            else {
                System.Console.WriteLine("Error creating the database");
            }
        }

        if (dbVersion == null || !dbVersion.Equals (Defines.VERSION)) {
            UpdateDatabase(file, dbVersion);
        }
    }
开发者ID:MonoBrasil,项目名称:historico,代码行数:49,代码来源:Database.cs

示例7: addDrone

    // Hier wird eine gegebene Drone in die Tabelle DRONEN eingefüllt
    public void addDrone(Drone drone)
    {
        IDbConnection _connection = new SqliteConnection(_strDBName);
        IDbCommand _command = _connection .CreateCommand();
        string sql;

        _connection .Open();

        sql = "INSERT INTO DRONEN (DRONENNAME,AKTUELLERKNOTEN,HOMEPUNKTID, STATUS,CARTOSHOW) Values ('"+ drone.getName()+"','2','2','0','ef')";
        _command.CommandText = sql;
        _command.ExecuteNonQuery();

        _command.Dispose();
        _command = null;
        _connection .Close();
        _connection.Dispose ();
        _connection = null;
        sql = null;
    }
开发者ID:Namamiri,项目名称:Parkplatzdrohne,代码行数:20,代码来源:Database.cs

示例8: addauto

    //Diese Methode Schreibt ein Gegebenes Auto in die Datenbank.
    // Das Auto wird als Parameter gegeben
    public void addauto(Autos autodaten)
    {
        IDbConnection _connection = new SqliteConnection(_strDBName);
        IDbCommand _command = _connection .CreateCommand();
        string sql;

        _connection .Open();

        sql = "INSERT INTO AUTOS (KENNZEICHEN, STATUS) Values ('"+ autodaten.getKennzeichen ()+"','"+autodaten.getStatus ()+"')";
        _command.CommandText = sql;
        _command.ExecuteNonQuery();

        _command.Dispose();
        _command = null;
        _connection .Close();
        _connection.Dispose ();
        _connection = null;
        //Debug.Log (autodaten.getKennzeichen ());
    }
开发者ID:Namamiri,项目名称:Parkplatzdrohne,代码行数:21,代码来源:Database.cs

示例9: Select

    public ArrayList Select(string quer)
    {
        Resultd = new ArrayList();
        string connectionString = "URI=file:" + Application.dataPath + "/Qjournaldb.s3db";
        IDbConnection dbcon = new SqliteConnection(connectionString);
        dbcon.Open();
        IDbCommand dbcmd = dbcon.CreateCommand();
        dbcmd.CommandText = quer;
        IDataReader reader = dbcmd.ExecuteReader();
        while (reader.Read())
        {
            Resultd.Add(reader.GetString(2));
            //Debug.Log(reader.GetString(2));
        }

        // clean up
        reader.Dispose();
        dbcmd.Dispose();
        dbcon.Close();
        return Resultd;
    }
开发者ID:neroes,项目名称:Phone-App-Project-1,代码行数:21,代码来源:Db.cs

示例10: abfrageexisttabelle

 // Hier wird überprüft ob eine bestimmte Tabelle in der Datenbank existieren. Die Anzahl der Funde wird Zurückgegeben. 1=Existiert; 0=Gibt es nicht
 public int abfrageexisttabelle(string Tabellenname)
 {
     IDbConnection _connection = new SqliteConnection(_strDBName);
     IDbCommand _command = _connection .CreateCommand();
     string sql;
     IDataReader _reader;
     _connection .Open();
     sql = "SELECT count(name) as Count FROM sqlite_master WHERE type='table' AND name='"+Tabellenname+"'";
     _command.CommandText = sql;
     _reader = _command.ExecuteReader();
     _reader.Read ();
     _connection .Close();
     _connection.Dispose ();
     _connection = null;
     _command.Dispose ();
     _command = null;
     int anzahl = System.Convert.ToInt32 (_reader ["Count"]);
     _reader.Close();
     _reader.Dispose ();
     _reader = null;
     return anzahl;
 }
开发者ID:Namamiri,项目名称:Parkplatzdrohne,代码行数:23,代码来源:Database.cs

示例11: getrandomparkingcar

    // Hier wird ein zufälliges PArkendes Auto zurückgesendet
    public Autos getrandomparkingcar()
    {
        IDbConnection _connection = new SqliteConnection(_strDBName);
        IDbCommand _command = _connection .CreateCommand();
        string sql;
        IDataReader _reader;

        _connection .Open();
        sql = "SELECT Count(KENNZEICHEN) as COUNT FROM AUTOS WHERE STATUS='2' ";
        _command.CommandText = sql;
        _reader = _command.ExecuteReader();
        _reader.Read ();
        int zufall = UnityEngine.Random.Range (1, System.Convert.ToInt32(_reader ["COUNT"]));
        _reader.Close ();
        sql = "SELECT * FROM AUTOS WHERE STATUS = '2' LIMIT "+ zufall;
        _command.CommandText = sql;
        _reader = _command.ExecuteReader();

        // Hier wird ein zufälliges Auto gesucht
        for (int i=0; i<zufall; i++) {
            _reader.Read();
                }
        Autos car = new Autos ();
        //Debug.Log (_reader ["KENNZEICHEN"]);
        car.setKennzeichen (System.Convert.ToString (_reader ["KENNZEICHEN"]));
        car.setStatus("2");
        _command.Dispose();
        _command = null;
        _connection .Close();
        _connection.Dispose ();
        _connection = null;
        _reader.Close ();
        _reader.Dispose ();
        _reader = null;
        return car;
    }
开发者ID:Namamiri,项目名称:Parkplatzdrohne,代码行数:37,代码来源:Database.cs

示例12: allesaufanfang

    //Hier wird die Datenbank wieder auf Anfang gesetzt. Alle Änderungen beim Letzten Ausführen des Programms werden gelöst
    public void allesaufanfang()
    {
        Debug.Log ("delete Car");
        IDbConnection _connection = new SqliteConnection(_strDBName);
        IDbCommand _command = _connection .CreateCommand();
        string sql;
        _connection.Open();
        sql = " Delete From AUTOS ";
        _command.CommandText = sql;
        _command.ExecuteNonQuery ();

        sql=" UPDATE PARKPLATZ SET KENNZEICHENFAHRZEUG='', FREI='1' WHERE FREI='0'";
        _command.CommandText = sql;
        _command.ExecuteNonQuery ();

        sql=" UPDATE DRONEN SET STATUS='0' WHERE STATUS > 0 ";
        _command.CommandText = sql;
        _command.ExecuteNonQuery ();

        _command.Dispose();
        _command = null;
        _connection .Close();
        _connection.Dispose ();
        _connection = null;
    }
开发者ID:Namamiri,项目名称:Parkplatzdrohne,代码行数:26,代码来源:Database.cs

示例13: fillTableDronen

    // Hier wird die Tabelle Drone gefüllt
    // Zurzeit ist es nur eine Drone
    public void fillTableDronen()
    {
        Debug.Log ("Dronen");
        IDbConnection _connection = new SqliteConnection(_strDBName);
        IDbCommand _command = _connection .CreateCommand();
        string sql;
        _connection.Open();
        sql = " Delete From DRONEN";
        _command.CommandText = sql;
        _command.ExecuteNonQuery ();

        _connection.Close ();
        _connection.Dispose ();
        _connection = null;
        _command.Dispose ();
        _command = null;

        Drone drone = new Drone ();
        drone.setName ("QuadCopter");drone.setStatus ("0");this.addDrone (drone);
        drone = null;
    }
开发者ID:Namamiri,项目名称:Parkplatzdrohne,代码行数:23,代码来源:Database.cs

示例14: OnGUI

    /// <summary>
    /// ////////////////////////////////////////Les fonctions liées aux gui
    /// </summary>

    void OnGUI()
    {
        //Debug.Log(idcarte);
        if (ObservJ1 == true)
        {
            if (GUI.Button(new Rect(710, 50, 200, 100), "Mettre dans le Deck"))
            {
                const string connectionString = "URI=file:E://Etude/Projet/Projet_4e_semestre/GITHUB/New_Unity_Project/Assets/testbdd.s3db";
                IDbConnection dbcon = new SqliteConnection(connectionString);
                IDbCommand dbcmd = dbcon.CreateCommand();
                try
                {
                    dbcon.Open();
                    string sql5 = "INSERT INTO j_deck_carte (IDDECK,IDCARTE) VALUES ('1'," + this.idcarte + ")";
                    dbcmd.CommandText = sql5;
                    IDataReader reader5 = dbcmd.ExecuteReader();
                    while (reader5.Read())
                    {
                    }
                    reader5.Dispose();
                }
                catch (Exception ex)
                {
                    Debug.Log(ex.Message);
                }
                dbcmd.Dispose();
                dbcon.Close();
            }
            if (GUI.Button(new Rect(710, 270, 200, 100), "Enlever du Deck"))
            {
                idcartebddJ1 = 0;
                const string connectionString = "URI=file:E://Etude/Projet/Projet_4e_semestre/GITHUB/New_Unity_Project/Assets/testbdd.s3db";
                IDbConnection dbcon = new SqliteConnection(connectionString);
                IDbCommand dbcmd = dbcon.CreateCommand();
                try
                {
                    dbcon.Open();
                    string sql6 = "DELETE FROM j_deck_carte WHERE IDDECK='1' AND IDCARTE='" + this.idcarte + "'";
                    dbcmd.CommandText = sql6;
                    IDataReader reader6 = dbcmd.ExecuteReader();
                    while (reader6.Read())
                    {
                    }
                    reader6.Dispose();
                }
                catch (Exception ex)
                {
                    Debug.Log(ex.Message);
                }
                dbcmd.Dispose();
                dbcon.Close();
            }
            if (GUI.Button(new Rect(710, 490, 200, 100), "Reposer"))
            {
                this.gameObject.transform.position = new Vector3(xdeck, ydeck, zdeck);
                ObservJ1 = false;
            }

        }


        if (ObservJ2 == true)
        {
            if (GUI.Button(new Rect(710, 50, 200, 100), "Mettre dans le Deck"))
            {
                const string connectionString = "URI=file:E://Etude/Projet/Projet_4e_semestre/GITHUB/New_Unity_Project/Assets/testbdd.s3db";
                IDbConnection dbcon = new SqliteConnection(connectionString);
                IDbCommand dbcmd = dbcon.CreateCommand();
                try
                {
                    dbcon.Open();
                    string sql7 = "INSERT INTO j_deck_carte (IDDECK,IDCARTE) VALUES ('2','" + this.idcarte + "')";
                    dbcmd.CommandText = sql7;
                    IDataReader reader7 = dbcmd.ExecuteReader();
                    while (reader7.Read())
                    {
                    }
                    reader7.Dispose();
                }
                catch (Exception ex)
                {
                    Debug.Log(ex.Message);
                }
                dbcmd.Dispose();
                dbcon.Close();
            }
            if (GUI.Button(new Rect(710, 270, 200, 100), "Enlever du Deck"))
            {
                idcartebddJ2 = 0;
                const string connectionString = "URI=file:E://Etude/Projet/Projet_4e_semestre/GITHUB/New_Unity_Project/Assets/testbdd.s3db";
                IDbConnection dbcon = new SqliteConnection(connectionString);
                IDbCommand dbcmd = dbcon.CreateCommand();
                try
                {
                    dbcon.Open();
                    string sql8 = "DELETE FROM j_deck_carte WHERE IDDECK='2' AND IDCARTE='" + this.idcarte + "'";
//.........这里部分代码省略.........
开发者ID:vnigaud,项目名称:Jeu_de_carte,代码行数:101,代码来源:ScriptCarteEffet.cs

示例15: InitializeDatabase

    /// <summary>Creates the database if necessary and returns the current
    /// iteration.</summary>
    protected int InitializeDatabase()
    {
      IDbConnection dbcon = new SqliteConnection(_db_con);
      dbcon.Open();
      IDbCommand dbcmd = dbcon.CreateCommand();
      string sql = "CREATE TABLE crawl (iter INTEGER, Address TEXT, Hits INTEGER, " +
        "Rtt REAL, Hops REAL)";
      dbcmd.CommandText = sql;
      try {
        dbcmd.ExecuteNonQuery();
      } catch {
      }

      sql = "CREATE TABLE iterations (iter INTEGER, time INTEGER)";
      dbcmd.CommandText = sql;
      try {
        dbcmd.ExecuteNonQuery();
      } catch {
      }

      // Set _current_iter to how many iterations there exist already
      sql = "SELECT iter FROM iterations";
      dbcmd.CommandText = sql;
      int current_iter = dbcmd.ExecuteNonQuery();
      dbcmd.Dispose();

      dbcon.Close();
      return current_iter;
    }
开发者ID:pstjuste,项目名称:brunet,代码行数:31,代码来源:NetworkTest.cs


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