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


C# SqliteConnection.Open方法代码示例

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


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

示例1: Initialise

        public void Initialise(string connectionString)
        {
            m_connectionString = connectionString;

            m_log.Info("[ESTATE DB]: Sqlite - connecting: "+m_connectionString);

            m_connection = new SqliteConnection(m_connectionString);
            m_connection.Open();

            Assembly assem = GetType().Assembly;
            Migration m = new Migration(m_connection, assem, "EstateStore");
            m.Update();

            m_connection.Close();
            m_connection.Open();

            Type t = typeof(EstateSettings);
            m_Fields = t.GetFields(BindingFlags.NonPublic |
                                   BindingFlags.Instance |
                                   BindingFlags.DeclaredOnly);

            foreach (FieldInfo f in m_Fields)
                if (f.Name.Substring(0, 2) == "m_")
                    m_FieldMap[f.Name.Substring(2)] = f;
        }
开发者ID:AlexRa,项目名称:opensim-mods-Alex,代码行数:25,代码来源:SQLiteEstateData.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: 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

示例4: SqliteStore

 public SqliteStore(string connectionString, string table)
     : base(table)
 {
     this.connectionString = connectionString;
     dbcon = new SqliteConnection(connectionString);
     dbcon.Open();
 }
开发者ID:JoshData,项目名称:semweb-dotnet,代码行数:7,代码来源:SQLiteStore.cs

示例5: 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

示例6: 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

示例7: SQLiteGenericData

        public SQLiteGenericData(string connectionString)
        {
            m_Connection = new SqliteConnection(connectionString);
            m_Connection.Open();

            Migration m = new Migration(m_Connection, this.GetType().Assembly, "GenericStore");
            m.Update();
        }
开发者ID:AlphaStaxLLC,项目名称:taiga,代码行数:8,代码来源:SQLiteGenericData.cs

示例8: 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

示例9: getNewConnection

 public virtual SqliteConnection getNewConnection()
 {
     SqliteConnectionStringBuilder conStringBuilder = new SqliteConnectionStringBuilder();
     conStringBuilder.Uri = config.DatabaseUri;
     conStringBuilder.Version = config.DatabaseVersion;
     SqliteConnection con = new SqliteConnection(conStringBuilder.ConnectionString);
     con.Open ();
     return con;
 }
开发者ID:Edhendil,项目名称:MonoLiteOrm,代码行数:9,代码来源:EntityManagerFactory.cs

示例10: 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

示例11: SqliteDataKit

 public SqliteDataKit()
 {
     conn = new SqliteConnection ();
     if (!File.Exists (Path.Combine (Configuration.GetInstance ().UserConfigDir, dbfile)))
     isNew = true;
     conn.ConnectionString = "URI=file:" + Path.Combine (Configuration.GetInstance ().UserConfigDir, dbfile);
     conn.Open ();
     if (isNew)
     SetupDb ();
 }
开发者ID:BackupTheBerlios,项目名称:mspace-svn,代码行数:10,代码来源:SqliteDataKit.cs

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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