예제 #1
4
        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);
            }
        }
예제 #2
1
        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();
                }
            }
        }
예제 #3
1
        public void UpdateDatabaseWithArteProps( string ConnectionString )
        {
            System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection( ConnectionString );
            conn.Open();
            System.Data.SQLite.SQLiteTransaction transaction = conn.BeginTransaction();
            System.Data.SQLite.SQLiteCommand command = new System.Data.SQLite.SQLiteCommand( conn );
            command.Transaction = transaction;
            foreach ( var a in ArteList ) {
                string UpdateNames = "UPDATE Text SET IdentifyString = \"" + a.Type.ToString() + ";\" || IdentifyString WHERE IdentifyString LIKE \"%[" + a.NameStringDicId + " / 0x" + a.NameStringDicId.ToString( "X6" ) + "]\"";
                Console.WriteLine( UpdateNames );
                command.CommandText = UpdateNames;
                command.ExecuteNonQuery();
                string UpdateDescs = "UPDATE Text SET IdentifyString = \"Description;\" || IdentifyString WHERE IdentifyString LIKE \"%[" + a.DescStringDicId + " / 0x" + a.DescStringDicId.ToString( "X6" ) + "]\"";
                Console.WriteLine( UpdateDescs );
                command.CommandText = UpdateDescs;
                command.ExecuteNonQuery();

                if ( a.Type == Arte.ArteType.Generic ) {
                    string UpdateStatus = "UPDATE Text SET status = 4, updated = 1, updatedby = \"[HyoutaTools]\", updatedtimestamp = " + Util.DateTimeToUnixTime( DateTime.UtcNow ) + " WHERE IdentifyString LIKE \"%[" + a.NameStringDicId + " / 0x" + a.NameStringDicId.ToString( "X6" ) + "]\"";
                    Console.WriteLine( UpdateStatus );
                    command.CommandText = UpdateStatus;
                    command.ExecuteNonQuery();
                }
            }
            command.Dispose();
            transaction.Commit();
            conn.Close();
            conn.Dispose();
        }
예제 #4
0
 public DbConnection Db()
 {
     if (!System.IO.File.Exists(File)) return null;
     var cn = new System.Data.SQLite.SQLiteConnection(string.Format("Data Source={0};Version=3;", File));
     cn.Open();
     return cn;
 }
		public SQLiteTransformationProvider(Dialect dialect, string connectionString)
			: base(dialect, connectionString, null)
		{
			_connection = new SqliteConnection(_connectionString);
			_connection.ConnectionString = _connectionString;
			_connection.Open();
		}
예제 #6
0
        public static IDbConnection GetDatabaseConnection(FileInfo database)
        {
            if (database == null) {
            throw new ArgumentNullException("database");
              }
              if (database.Exists && database.IsReadOnly) {
            throw new ArgumentException("Database file is read only", "database");
              }
              var cs = string.Format("Uri=file:{0}", database.FullName);
              if (Type.GetType("Mono.Runtime") == null) {
            var rv = new System.Data.SQLite.SQLiteConnection(cs);
            if (rv == null) {
              throw new ArgumentException("no connection");
            }
            rv.Open();
            return rv;
              }

              Assembly monoSqlite;
              try {
            monoSqlite = Assembly.Load("Mono.Data.Sqlite, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756");
              }
              catch (Exception) {
            monoSqlite = Assembly.Load("Mono.Data.Sqlite, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756");
              }
              var dbconn = monoSqlite.GetType("Mono.Data.Sqlite.SqliteConnection");
              var ctor = dbconn.GetConstructor(new[] { typeof(string) });
              var mrv = ctor.Invoke(new[] { cs }) as IDbConnection;
              if (mrv == null) {
            throw new ArgumentException("no connection");
              }
              mrv.Open();
              return mrv;
        }
예제 #7
0
파일: Sqlite.cs 프로젝트: itsmevix/FTT-DLNA
    private static IDbConnection GetDatabaseConnectionSDS(string cs)
    {
      var rv = new System.Data.SQLite.SQLiteConnection(cs);
      if (rv == null) {
        throw new ArgumentException("no connection");
      }
      rv.Open();

      try {
        rv.SetChunkSize(GROW_SIZE);
      }
      catch (Exception ex) {
        log4net.LogManager.GetLogger(typeof(Sqlite)).Error(
          "Failed to sqlite control", ex);
      }

      if (clearPool == null) {
        clearPool = conn =>
        {
          System.Data.SQLite.SQLiteConnection.ClearPool(
            conn as System.Data.SQLite.SQLiteConnection);
        };
      }
      return rv;
    }
예제 #8
0
        public static IDbConnection CreateConnection()
        {
            var connection = new System.Data.SQLite.SQLiteConnection(GetConnectionString());
            connection.Open();

            return connection;
        }
 public SQLiteTransformationProvider(Dialect dialect, string connectionString)
     : base(dialect, connectionString)
 {
     connection = new SqliteConnection(base.connectionString);
     connection.ConnectionString = base.connectionString;
     connection.Open();
 }
예제 #10
0
        public static int Execute( List<string> args )
        {
            // 0xCB20

            if ( args.Count != 2 ) {
                Console.WriteLine( "Generates a scenario db for use in Tales.Vesperia.Website from a MAPLIST.DAT." );
                Console.WriteLine( "Usage: maplist.dat scenario.db" );
                return -1;
            }

            String maplistFilename = args[0];
            string connStr = "Data Source=" + args[1];

            using ( var conn = new System.Data.SQLite.SQLiteConnection( connStr ) ) {
                conn.Open();
                using ( var ta = conn.BeginTransaction() ) {
                    SqliteUtil.Update( ta, "CREATE TABLE descriptions( filename TEXT PRIMARY KEY, shortdesc TEXT, desc TEXT )" );
                    int i = 0;
                    foreach ( MapName m in new MapList( System.IO.File.ReadAllBytes( maplistFilename ) ).MapNames ) {
                        Console.WriteLine( i + " = " + m.ToString() );
                        List<string> p = new List<string>();
                        p.Add( "VScenario" + i );
                        p.Add( m.Name1 != "dummy" ? m.Name1 : m.Name3 );
                        p.Add( m.Name1 != "dummy" ? m.Name1 : m.Name3 );
                        SqliteUtil.Update( ta, "INSERT INTO descriptions ( filename, shortdesc, desc ) VALUES ( ?, ?, ? )", p );
                        ++i;
                    }
                    ta.Commit();
                }
                conn.Close();
            }

            return 0;
        }
예제 #11
0
        public List<String> getLastProjects()
        {
            List<String> list = new List<String>();
            using (System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection("data source=databaseFile.db3"))
            {
                using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(con))
                {
                    con.Open();

                    com.CommandText = "Select * FROM LASTPROJECTS";

                    using (System.Data.SQLite.SQLiteDataReader reader = com.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Console.WriteLine(reader["address"]);

                           list.Add(reader["address"].ToString());
                        }
                    }
                    con.Close();
                }
            }
            return list;
        }
예제 #12
0
        public DatabaseManager()
        {
            string createTableQuery = @"CREATE TABLE IF NOT EXISTS LASTPROJECTS (
                          [ID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
                          [address] VARCHAR(2048)  NULL
                          )";
            string path = Path.
                GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()));
            path = path + @"\bin\Debug\databaseFile.db3";

            if(!File.Exists (path))
                System.Data.SQLite.SQLiteConnection.CreateFile("databaseFile.db3");

            using (System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection("data source=databaseFile.db3"))
            {
                using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(con))
                {
                    con.Open();
                    com.CommandText = createTableQuery;
                    com.ExecuteNonQuery();
                    con.Close();
                }
            }
            Console.WriteLine("ALLO");
        }
        // "x:\util\android-sdk-windows\platform-tools\adb.exe"  tcpip 5555
        // restarting in TCP mode port: 5555

        // "x:\util\android-sdk-windows\platform-tools\adb.exe" connect 192.168.1.126:5555
        // connected to 192.168.1.126:5555

        static ApplicationWebService()
        {
            // will this work for android?

            Console.WriteLine("ApplicationWebService cctor " + new { Environment.CurrentDirectory });

            // ApplicationWebService cctor { CurrentDirectory = W:\staging.net.debug }

            #region setup:QueryExpressionBuilder.WithConnection
            //if (ScriptCoreLib.Query.Experimental.QueryExpressionBuilder.WithConnection == null)

            // override the default
            ScriptCoreLib.Query.Experimental.QueryExpressionBuilder.WithConnection =
                y =>
                {
                    // relative path?
                    var DataSource = "file:server1.sqlite";

                    // nuget xsqlite?
                    var cc = new System.Data.SQLite.SQLiteConnection(new System.Data.SQLite.SQLiteConnectionStringBuilder
                    {
                        DataSource = DataSource,
                        Version = 3
                    }.ConnectionString);
                    cc.Open();
                    y(cc);
                    cc.Dispose();
                };
            #endregion
        }
예제 #14
0
        static void Main1(string[] args)
        {
            string datasource = "test.db";

            System.Data.SQLite.SQLiteConnection.CreateFile(datasource);

            //连接数据库

            System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection();

            System.Data.SQLite.SQLiteConnectionStringBuilder connstr =

                new System.Data.SQLite.SQLiteConnectionStringBuilder();

            connstr.DataSource = datasource;

            connstr.Password = "******";//设置密码,SQLite ADO.NET实现了数据库密码保护
            Console.WriteLine(connstr.ToString());
            conn.ConnectionString = connstr.ToString();

            conn.Open();

            //创建表

            System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand();

            string sql = "CREATE TABLE test(username varchar(20),password varchar(20))";

            cmd.CommandText = sql;

            cmd.Connection = conn;

            cmd.ExecuteNonQuery();

            //插入数据

            sql = "INSERT INTO test VALUES('dotnetthink','mypassword')";

            cmd.CommandText = sql;

            cmd.ExecuteNonQuery();

            //取出数据

            sql = "SELECT * FROM test";

            cmd.CommandText = sql;

            System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader();

            StringBuilder sb = new StringBuilder();

            while (reader.Read())
            {
                sb.Append("username:"******"\n").Append("password:").Append(reader.GetString(1));

            }
            Console.WriteLine(sb.ToString());
        }
예제 #15
0
 public PurchaseOrderModel GetOne(int id)
 {
     using (IDbConnection connection = new System.Data.SQLite.SQLiteConnection(GlobalConfig.CnnString()))
     {
         string query = "select * from Narudzbenice where Id = @ID";
         return(connection.QuerySingle <PurchaseOrderModel>(query, new { Id = id }));
     }
 }
예제 #16
0
 public List <PurchaseOrderModel> GetAllOlderThen(int days)
 {
     using (IDbConnection connection = new System.Data.SQLite.SQLiteConnection(GlobalConfig.CnnString()))
     {
         string query = "SELECT * FROM Narudzbenice WHERE(julianday('now') - julianday(DatumNarudzbenice)) <= " + days + "; ";
         return((List <PurchaseOrderModel>)connection.Query <PurchaseOrderModel>(query));
     }
 }
예제 #17
0
        //public List<PurchaseOrederPositionModel> NarudbeniceSaPozicijam()
        //{
        //    // TODO: ovde sis tao 01.03.2020 u 14:34
        //    PurchaseOrederPositionModel p = new PurchaseOrederPositionModel();
        //    List<PurchaseOrederPositionModel> modeli = new List<PurchaseOrederPositionModel>();
        //    using (IDbConnection connection = new System.Data.SQLite.SQLiteConnection(GlobalConfig.CnnString()))
        //    {

        //        //string query = "SELECT * FROM Narudzbenice INNER JOIN Pozicije on Pozicije.Narudzbenica_ID = Narudzbenice.ID";
        //        string query1 = "SELECT * FROM Narudzbenice; SELECT * FROM Pozicije";
        //        //return connection.QuerySingle<NarudzbenicaModel>(query, new { Id = id });
        //        List<PurchaseOrderModel> nardudzbenice = new List<PurchaseOrderModel>();
        //        List<PositionModel> pozicije = new List<PositionModel>();
        //        List<PositionModel> jednaPozicija = new List<PositionModel>();
        //        var multi = connection.QueryMultiple(query1, null);

        //        nardudzbenice = multi.Read<PurchaseOrderModel>().ToList();
        //        pozicije = multi.Read<PositionModel>().ToList();
        //        foreach (PurchaseOrderModel narudzbenica in nardudzbenice)
        //        {
        //            foreach (PositionModel po in pozicije)
        //            {
        //                if (narudzbenica.ID == po.PozicijeId)
        //                {
        //                    jednaPozicija.Add(po);
        //                }
        //            }
        //            modeli.Add(new NarudzbenicaPozicijaModel(narudzbenica.ID,
        //                narudzbenica.BrojNarudzbenice,
        //                narudzbenica.DatumNarudzbenice,
        //                narudzbenica.DatumIstekaRokaNarudzbenice,
        //                narudzbenica.OkvirniSporazum,
        //                narudzbenica.Ogranak,
        //                narudzbenica.NazivTrafostanice,
        //                narudzbenica.DatumFakture,
        //                narudzbenica.BrojFakture,
        //                narudzbenica.IznosBezPDV,
        //                narudzbenica.DatumPrijemEPS,
        //                narudzbenica.BrojIzvestaja,
        //                narudzbenica.Napomena,
        //                narudzbenica.IzvestajPoslat,
        //                narudzbenica.NarudzbenicaPDF,
        //                narudzbenica.ZapsinikOIzvrsenjuUslugaPDF,
        //                narudzbenica.FakturaPDF,
        //                narudzbenica.PrimopredajniObrazacPDF,
        //                narudzbenica.Korisnik, narudzbenica.Datum, jednaPozicija));
        //            //p.Id = narudzbenica.ID;
        //            //p.BrojNarudzbenice = narudzbenica.BrojNarudzbenice;
        //            //p.DatumNarudzbenice = narudzbenica.DatumNarudzbenice;
        //            //p.DatumIstekaRokaNarudzbenice = narudzbenica.DatumIstekaRokaNarudzbenice;
        //            //p.OkvirniSporazum = narudzbenica.OkvirniSporazum;
        //            //p.Ogranak = narudzbenica.Ogranak;
        //            //p.NazivTrafostanice = narudzbenica.NazivTrafostanice;
        //            //p.DatumFakture = narudzbenica.DatumFakture;
        //            //p.BrojFakture = narudzbenica.BrojFakture;
        //            //p.IznosBezPDV = narudzbenica.IznosBezPDV;
        //            //p.DatumPrijemEPS = narudzbenica.DatumPrijemEPS;
        //            //p.BrojIzvestaja = narudzbenica.BrojIzvestaja;
        //            //p.Napomena = narudzbenica.Napomena;
        //            //p.IzvestajPoslat = narudzbenica.IzvestajPoslat;
        //            //p.NarudzbenicaPDF = narudzbenica.NarudzbenicaPDF;
        //            //p.ZapsinikOIzvrsenjuUslugaPDF = narudzbenica.ZapsinikOIzvrsenjuUslugaPDF;
        //            //p.FakturaPDF = narudzbenica.FakturaPDF;
        //            //p.PrimopredajniObrazacPDF = narudzbenica.PrimopredajniObrazacPDF;
        //            //p.Korisnik = narudzbenica.Korisnik;
        //            //p.Datum = narudzbenica.Datum;

        //        }
        //        //var invoice = multi.Read<Invoice>().First();
        //        //var invoiceItems = multi.Read<InvoiceItem>().ToList();
        //        //try
        //        //{
        //        //    //return (List<NarudzbenicaPozicijaModel>)connection.Query<NarudzbenicaPozicijaModel>(query);
        //        //    //var inerJoin = connection.Query<NarudzbenicaPozicijaModel, PozicijaModel, NarudzbenicaPozicijaModel>(query,(narudzbenicapozicijamodel, pozicijamodel) => pozicijamodel)
        //        //}
        //        //catch (Exception ex)
        //        //{

        //        //    MessageBox.Show("Doslo je do greske, detaljne informaciju su: " + ex, "Greska sa bazom!", MessageBoxButtons.OK, MessageBoxIcon.Error);
        //        //    return null;
        //        //}
        //        // Step 1: Use Dapper to return the  flat result as a Dynamic.
        //        //dynamic test = connection.Query<dynamic>(query);

        //        //NarudzbenicaPozicijaModel pozicija = new NarudzbenicaPozicijaModel();
        //        //pozicija.Id = test.Id;// d.GetType().GetProperty("value2").GetValue(d, null);
        //        //pozicija.Id = test.GetType().GetProperty("Id").GetValue(db, null);
        //        //pozicija.BrojNarudzbenice = test.BrojNarudzbenice;



        //        // Step 2: Use Slapper.Automapper for mapping to the POCO Entities.
        //        // - IMPORTANT: Let Slapper.Automapper know how to do the mapping;
        //        //   let it know the primary key for each POCO.
        //        // - Must also use underscore notation ("_") to name parameters;
        //        //   see Slapper.Automapper docs.
        //        //Slapper.AutoMapper.Configuration.AddIdentifiers(typeof(NarudzbenicaPozicijaModel), new List<string> { "Id" });
        //        //Slapper.AutoMapper.Configuration.AddIdentifiers(typeof(PozicijaModel), new List<string> { "PozicijeId" });

        //        //p = (Slapper.AutoMapper.MapDynamic<NarudzbenicaPozicijaModel>(test) as IEnumerable<NarudzbenicaPozicijaModel>).ToList();
        //        //var testContact = (Slapper.AutoMapper.MapDynamic<NarudzbenicaPozicijaModel>(test) as IEnumerable<NarudzbenicaPozicijaModel>).ToList();

        //        return modeli;
        //    }
        //}



        public void RemoveUser(int id)
        {
            using (IDbConnection connection = new System.Data.SQLite.SQLiteConnection(GlobalConfig.CnnString()))
            {
                string query = "delete from Korisnici where ID = @ID";
                int    i     = connection.Execute(query, new { id = id });
            }
        }
예제 #18
0
        public static IDbConnection CreateConnection()
        {
            var connection = new System.Data.SQLite.SQLiteConnection(GetConnectionString());

            connection.Open();

            return(connection);
        }
예제 #19
0
 public void RegisterConnection()
 {
     if (DBConnection == null || DBConnection.State == ConnectionState.Closed)
     {
         DBConnection = new System.Data.SQLite.SQLiteConnection(ConnectionString);
         DBConnection.Open();
     }
 }
예제 #20
0
 public List <PurchaseOrderModel> GetAllWhereIzvestajPoslat(int poslat, string y)
 {
     using (IDbConnection connection = new System.Data.SQLite.SQLiteConnection(GlobalConfig.CnnString()))
     {
         string query = "SELECT * FROM Narudzbenice where IzvestajPoslat = " + poslat + " AND strftime('%Y', Datum) = '" + y + "';";
         return((List <PurchaseOrderModel>)connection.Query <PurchaseOrderModel>(query));
     }
 }
예제 #21
0
 internal static System.Data.IDbConnection SQLiteConn()
 {
     string strConn = System.Windows.Forms.Application.StartupPath + "//Database.db";
     System.Data.SQLite.SQLiteConnectionStringBuilder strBuild = new System.Data.SQLite.SQLiteConnectionStringBuilder();
     strBuild.DataSource = strConn;
     System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection(strBuild.ToString());
     return conn;
 }
예제 #22
0
 public List <PurchaseOrderModel> GetAllForThisYear(string y)
 {
     using (IDbConnection connection = new System.Data.SQLite.SQLiteConnection(GlobalConfig.CnnString()))
     {
         string query = "SELECT * FROM Narudzbenice WHERE strftime('%Y', Datum) = '" + DateTime.Now.Year.ToString() + "'";
         return((List <PurchaseOrderModel>)connection.Query <PurchaseOrderModel>(query));
     }
 }
예제 #23
0
        private void Btn_startPersonInfo_Click(object sender, System.EventArgs e)
        {
            listview_personInfos.Items.Clear();
            System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection(sDataBaseStr);
            conn.Open();
            //
            string sql_findInfo = "select * from RentPersonInfo order by personCardNum";

            if (cb_personCondition.SelectedIndex == 1)
            {
                sql_findInfo = string.Format("select * from RentPersonInfo where personName = '{0}'", tb_personCondition.Text);
            }
            else if (cb_personCondition.SelectedIndex == 2)
            {
                sql_findInfo = string.Format("select * from RentPersonInfo where personCardNum = '{0}'", tb_personCondition.Text);
            }
            else if (cb_personCondition.SelectedIndex == 3)
            {
                sql_findInfo = string.Format("select * from RentPersonInfo where mobile = '{0}'", tb_personCondition.Text);
            }

            System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand();
            cmd.CommandText = sql_findInfo;
            cmd.Connection  = conn;
            System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader();
            if (reader.HasRows)
            {
                this.listview_personInfos.BeginUpdate();
                while (reader.Read())
                {
                    string personName   = reader.GetString(0);
                    string personNum    = reader.GetString(1);
                    string personCardNo = reader.GetString(2);
                    string mobile       = reader.GetString(3);

                    //
                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = personName;
                    lvi.SubItems.Add(personNum);
                    lvi.SubItems.Add(personCardNo);
                    lvi.SubItems.Add(mobile);

                    if (personName.Contains("已销卡"))
                    {
                        lvi.ForeColor = Color.ForestGreen;
                    }
                    listview_personInfos.Items.Add(lvi);
                }
                this.listview_personInfos.EndUpdate();
            }
            //
            reader.Close();
            cmd.Dispose();
            conn.Close();
            conn.Dispose();
            System.GC.Collect();
            System.GC.WaitForPendingFinalizers();
        }
예제 #24
0
        public Form1()
        {
            InitializeComponent();
            //System.Data.SQLite.SQLiteConnection.CreateFile("MyDatabase.sqlite");

            m_dbConnection = new System.Data.SQLite.SQLiteConnection("Data Source=..\\..\\Data\\SustainableChemistry.sqlite;Version=3;");
            m_dbConnection.Open();

            FunctionalGroups     = new DataTable();
            NamedReactions       = new DataTable();
            molecule             = new ChemInfo.Molecule();
            fGroups              = new ChemInfo.FunctionalGroupCollection();
            reactions            = new ChemInfo.NamedReactionCollection();
            this.trackBar1.Value = (int)(this.moleculeViewer1.Zoom * 100);
            documentPath         = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\USEPA\\SustainableChemistry";

            this.OpenFunctionGroupExcelResource();

            System.IO.FileStream fs = new System.IO.FileStream("..\\..\\Data\\references.dat", System.IO.FileMode.Open);

            // Construct a BinaryFormatter and use it to serialize the data to the stream.
            System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
            try
            {
                m_References = (ChemInfo.References)formatter.Deserialize(fs);
            }
            catch (System.Runtime.Serialization.SerializationException e)
            {
                Console.WriteLine("Failed to deserialize. Reason: " + e.Message);
                throw;
            }
            finally
            {
                fs.Close();
            }


            //Reads in functional groups from JSON file. This should be used after Excel file is completed.
            //var json = new System.Web.Script.Serialization.JavaScriptSerializer();
            //functionalGroups = (List<ChemInfo.FunctionalGroup>)json.Deserialize(ChemInfo.Functionalities.AvailableFunctionalGroups(), typeof(List<ChemInfo.FunctionalGroup>));            // string text = ChemInfo.Functionalities.FunctionalGroups("P(c1ccccc1)(c1ccccc1)(N)=O", "json");

            // Test code for generating a results file from a functional group name.
            //Results res = new Results("phosphoramidite", m_References);
            //string results = json.Serialize(res);

            // Initial code to load references from text RIS resource files. Can be deleted when done.
            //m_References = new ChemInfo.References();
            //m_References.Add(new ChemInfo.Reference("phosphoramidite", "Diisoproprylethyamine Solvent", enc8.GetString(Properties.Resources.S0040403900813763)));
            //m_References.Add(new ChemInfo.Reference("phosphoramidite", "Diisoproprylethyamine Solvent", enc8.GetString(Properties.Resources.S0040403900942163)));
            //m_References.Add(new ChemInfo.Reference("phosphoramidite", "Diisoproprylethyamine Solvent", enc8.GetString(Properties.Resources.S0040403901904617)));
            //m_References.Add(new ChemInfo.Reference("phosphoramidite", "Diisoproprylethyamine Solvent", enc8.GetString(Properties.Resources.achs_jacsat105_661)));
            //m_References.Add(new ChemInfo.Reference("phosphate", "No Name", enc8.GetString(Properties.Resources.S1001841712003142)));
            //m_References.Add(new ChemInfo.Reference("phosphate", "Catalyst", Properties.Resources._10_1002_2Fchin_199605199));
            //m_References.Add(new ChemInfo.Reference("phosphoramidite", "Catalyst Solvent", enc8.GetString(Properties.Resources.europepmc)));
            //m_References.Add(new ChemInfo.Reference("phosphoramidite", "Catalyst Solvent", enc8.GetString(Properties.Resources.europepmc1)));
            //m_References.Add(new ChemInfo.Reference("phosphoramidite", "Catalyst Solvent", enc8.GetString(Properties.Resources.achs_oprdfk4_175)));
            //m_References.Add(new ChemInfo.Reference("phosphoramidite", "Catalyst Solvent", enc8.GetString(Properties.Resources.BIB)));
        }
예제 #25
0
        public static void SetSQLiteDBpwd(string absPath, string pwd)
        {
            string connStr = string.Format("Data Source={0};", absPath);

            System.Data.SQLite.SQLiteConnection connection = new System.Data.SQLite.SQLiteConnection(connStr);
            connection.Open();
            connection.ChangePassword(pwd);
            connection.Close();
        }
예제 #26
0
        internal static System.Data.IDbConnection SQLiteConn()
        {
            string strConn = System.Windows.Forms.Application.StartupPath + "//Database.db";

            System.Data.SQLite.SQLiteConnectionStringBuilder strBuild = new System.Data.SQLite.SQLiteConnectionStringBuilder();
            strBuild.DataSource = strConn;
            System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection(strBuild.ToString());
            return(conn);
        }
예제 #27
0
 public void DeregisterConnection()
 {
     if (DBConnection != null && DBConnection.State != ConnectionState.Closed)
     {
         DBConnection?.Close();
         DBConnection?.Dispose();
     }
     DBConnection = null;
 }
예제 #28
0
        public DatabaseGateway(string databasePath)
        {
            _DBConnection = new System.Data.SQLite.SQLiteConnection(databasePath);

            if (!DatabaseConnectionIsValid())
            {
                // i'm not sure yet what should happen here
            }
        }
예제 #29
0
        public void Command()
        {
            using (var conn = new System.Data.SQLite.SQLiteConnection("Data Source=:memory:"))
            {
                conn.Open();

                using (var command = new LoggingCommand(new System.Data.SQLite.SQLiteCommand()))
                {
                    command.CommandText = "select 1";
                    Assert.Throws<InvalidOperationException>(() => command.ExecuteReader());
                    Assert.Equal(LogLevel.Error, logger.Last.Level);
                    Assert.Equal(@"クエリ実行に失敗
            --- SQLiteCommand ---
            CommandTimeout   = 30
            CommandType      = Text
            UpdatedRowSource = None
            --- CommandText ---
            select 1
            --- Parameters ---
            ", logger.Last.Message);

                    command.Connection = conn;
                    using (var reader = command.ExecuteReader())
                    {
                        Assert.Equal(LogLevel.Trace, logger.Last.Level);
                        Assert.Matches(@"ExecuteReader. 実行時間:\d\d:\d\d:\d\d\.\d+
            --- CommandText ---
            select 1
            --- Parameters ---
            ", logger.Last.Message);

                        Assert.True(reader.Read());
                        Assert.Equal((long)1, reader[0]);
                    }

                    Assert.Equal((long)1, command.ExecuteScalar());
                    Assert.Matches(@"ExecuteScalar. result=1 実行時間:\d\d:\d\d:\d\d\.\d+
            --- CommandText ---
            select 1
            --- Parameters ---
            ", logger.Last.Message);

                    command.CommandText = "select @p";
                    command.Parameters.Add(new System.Data.SQLite.SQLiteParameter("p", "abc"));
                    Assert.Equal("abc", command.ExecuteScalar());
                    Assert.Matches(@"ExecuteScalar. result=abc 実行時間:\d\d:\d\d:\d\d\.\d+
            --- CommandText ---
            select @p
            --- Parameters ---
            p\(String\)=abc
            ", logger.Last.Message);

                    Assert.IsType<System.Data.SQLite.SQLiteParameter>(command.CreateParameter());
                }
                Assert.Equal("コマンドが破棄(Dispose)されました。", logger.Last.Message);
            }
        }
        public virtual DatabaseModel Create(string connectionString, IEnumerable <string> tables, IEnumerable <string> schemas)
        {
            var modelFactory = new  SqliteDatabaseModelFactory(_logger);

            using (var connection = new System.Data.SQLite.SQLiteConnection(connectionString))
            {
                return(modelFactory.Create(connection, tables, schemas));
            }
        }
예제 #31
0
 public PositionModel NapraviPoziciju(PositionModel pozicija)
 {
     using (IDbConnection connection = new System.Data.SQLite.SQLiteConnection(GlobalConfig.CnnString()))
     {
         string query = @"Insert into [Pozicije](PozicijeId,Narudzbenica_ID, ImePozicije) values  (null, @Narudzbenica_ID, @ImePozicije);";
         connection.Execute(query, pozicija, commandType: CommandType.Text);
         return(pozicija);
     }
 }
예제 #32
0
 public int UkupanBrojUnosaZaKorisnika(string korisnik)
 {
     using (IDbConnection connection = new System.Data.SQLite.SQLiteConnection(GlobalConfig.CnnString()))
     {
         string query = "select count() from Narudzbenice where Korisnik = '" + korisnik + "';";
         //return connection.QuerySingle<int>(query, new { ID = id });
         return(connection.ExecuteScalar <int>(query));
     }
 }
예제 #33
0
 /// <summary>
 /// Parametar nam sluzi da bi birali izmedju poslatih i neposlatih izvestaja
 /// </summary>
 /// <param name="i"> 0 ili 1 </param>
 /// <returns></returns>
 public int SumaIzvestajPosla(int i)
 {
     using (IDbConnection connection = new System.Data.SQLite.SQLiteConnection(GlobalConfig.CnnString()))
     {
         string query = "select count() from Narudzbenice where IzvestajPoslat = " + i + ";";
         //return connection.QuerySingle<int>(query, new { ID = id });
         return(connection.ExecuteScalar <int>(query));
     }
 }
예제 #34
0
        public IEnumerable <Chromium.Cookie> GetCookiesBy(Chromium.CookieHeader by, object value, byte[] key)
        {
            List <Chromium.Cookie> cookies = new List <Chromium.Cookie>();

            if (value == null)
            {
                throw new ArgumentNullException("value");                // throw a ArgumentNullException if value was not defined
            }
            if (!CookiesExist())
            {
                throw new CookieDatabaseNotFoundException(ChromiumBrowserCookiePath);                  // throw a CookieDatabaseNotFoundException if the Cookie DB was not found
            }
            // Copy the database to a temporary location because it could be already in use
            string tempFile = GetTempFileName();

            File.Copy(ChromiumBrowserCookiePath, tempFile);

            using (var conn = new System.Data.SQLite.SQLiteConnection($"Data Source={tempFile};pooling=false"))
                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandText = $"{CookieCommandText} WHERE {by} = '{value}'";

                    conn.Open();
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            // Store retrieved information:
                            cookies.Add(new Chromium.Cookie()
                            {
                                CreationUTC     = reader.GetInt64(0),
                                TopFrameSiteKey = reader.GetString(1),
                                HostKey         = reader.GetString(2),
                                Name            = reader.GetString(3),
                                Value           = reader.GetString(4),
                                EncryptedValue  = DecryptWithKey((byte[])reader[5], key, 3),
                                Path            = reader.GetString(6),
                                ExpiresUTC      = reader.GetInt64(7),
                                IsSecure        = reader.GetBoolean(8),
                                IsHttpOnly      = reader.GetBoolean(9),
                                LastAccessUTC   = reader.GetInt64(10),
                                HasExpires      = reader.GetBoolean(11),
                                IsPersistent    = reader.GetBoolean(12),
                                Priority        = reader.GetInt16(13),
                                Samesite        = reader.GetInt16(14),
                                SourceScheme    = reader.GetInt16(15),
                                SourcePort      = reader.GetInt32(16),
                                IsSameParty     = reader.GetBoolean(17),
                            });
                        }
                    }
                    conn.Close();
                }
            File.Delete(tempFile);

            return(cookies);
        }
        public void SaveScenarioNotes()
        {
            ado_data_access p_ado = null;

            SQLite.ADO.DataMgr oDataMgr       = null;
            string             strNotes       = this.txtNotes.Text;
            string             strProjDir     = frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim();
            string             strScenarioDir = strProjDir + "\\" + ScenarioType + "\\db";

            if ((ReferenceProcessorScenarioForm != null && !ReferenceProcessorScenarioForm.m_bUsingSqlite) ||
                ScenarioType.Trim().ToUpper() == "OPTIMIZER")
            {
                p_ado    = new ado_data_access();
                strNotes = p_ado.FixString(strNotes, "'", "''");
                string strSQL = "";
                if (ScenarioType.Trim().ToUpper() == "OPTIMIZER")
                {
                    strSQL = "UPDATE scenario SET notes = '" +
                             strNotes +
                             "' WHERE trim(lcase(scenario_id)) = '" + ((frmOptimizerScenario)this.ParentForm).uc_scenario1.txtScenarioId.Text.Trim().ToLower() + "';";
                }
                else
                {
                    strSQL = "UPDATE scenario SET notes = '" +
                             strNotes +
                             "' WHERE trim(lcase(scenario_id)) = '" + this.ReferenceProcessorScenarioForm.uc_scenario1.txtScenarioId.Text.Trim().ToLower() + "';";
                }
                System.Data.OleDb.OleDbConnection oConn = new System.Data.OleDb.OleDbConnection();
                string        strFile     = "scenario_" + ScenarioType + "_rule_definitions.mdb";
                StringBuilder strFullPath = new StringBuilder(strScenarioDir);
                strFullPath.Append("\\");
                strFullPath.Append(strFile);
                string strConn = p_ado.getMDBConnString(strFullPath.ToString(), "admin", "");
                p_ado.SqlNonQuery(strConn, strSQL);
                p_ado = null;
            }
            else
            {
                oDataMgr = new SQLite.ADO.DataMgr();
                strNotes = oDataMgr.FixString(strNotes, "'", "''");
                //@ToDo: Only support Processor at this time
                string strSQL = "UPDATE scenario SET notes = '" +
                                strNotes +
                                "' WHERE trim(lower(scenario_id)) = '" + this.ReferenceProcessorScenarioForm.uc_scenario1.txtScenarioId.Text.Trim().ToLower() + "';";
                string        strFile     = "scenario_" + ScenarioType + "_rule_definitions.db";
                StringBuilder strFullPath = new StringBuilder(strScenarioDir);
                strFullPath.Append("\\");
                strFullPath.Append(strFile);
                string strConn = oDataMgr.GetConnectionString(strFullPath.ToString());
                using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection(strConn))
                {
                    conn.Open();
                    oDataMgr.SqlNonQuery(conn, strSQL);
                }
                oDataMgr = null;
            }
        }
예제 #36
0
 public void TestConnection()
 {
     //Using System.Data.SQLite.dll
     using (System.Data.SQLite.SQLiteConnection Conn = new System.Data.SQLite.SQLiteConnection(this.ConnStr)) {
         Conn.Open();
         Conn.Close();
         Conn.Dispose();
     }
 }
예제 #37
0
        private void draw()
        {
            //string drawQuery = "select top 1 name from LotContestents where ObjectGuid = '" + objectGuid + "' and LotDrawNumber = '" + rdr["ActiveDrawNumber"].ToString() + "' ORDER BY NEWID()";
            string lotNumberSelectQuery = "select * from LotObjectsInWorld where ObjectGuid = '" + objectGuid + "'";
            string winnerUpdateSql      = "";
            string lotNumber            = "";
            string winner = "";

            using (System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection("data source=" + HttpContext.Current.Server.MapPath("~/App_Data/Raffle.db")))
            {
                using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(con))
                {
                    con.Open();                             // Open the connection to the database

                    com.CommandText = lotNumberSelectQuery; // Set CommandText to our query that will create the table

                    using (System.Data.SQLite.SQLiteDataReader reader = com.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            string drawQuery = "select name from LotContestents where ObjectGuid = '" + objectGuid + "' and LotDrawNumber = '" + reader["LotDrawNumber"].ToString() + "' ORDER BY RANDOM() LIMIT 1";
                            lotNumber = reader["LotDrawNumber"].ToString();
                            reader.Close();
                            com.CommandText = drawQuery;
                            using (System.Data.SQLite.SQLiteDataReader reader1 = com.ExecuteReader())
                            {
                                if (reader1.Read())
                                {
                                    winnerUpdateSql = "update LotDrawHistory set Winner = '" + reader1[0].ToString() + "' where ObjectGuid = '" + objectGuid + "' and LotDrawNumber = '" + lotNumber + "'";
                                    winner          = reader1[0].ToString();
                                    reader1.Close();
                                    com.CommandText = winnerUpdateSql;
                                    com.ExecuteNonQuery();
                                    pageResponse.Write(winner.Replace("$", " "));
                                    pageResponse.Flush();
                                    pageResponse.SuppressContent = true;
                                }
                                else
                                {
                                    winnerUpdateSql = "update LotDrawHistory set Winner = '$$$' where ObjectGuid = '" + objectGuid + "' and LotDrawNumber = '" + lotNumber + "'";
                                    reader1.Close();
                                    com.CommandText = winnerUpdateSql;
                                    com.ExecuteNonQuery();
                                    pageResponse.Write("$$$"); // code for no winners
                                    pageResponse.Flush();
                                    pageResponse.SuppressContent = true;
                                }
                            }
                        }
                    }

                    con.Close();
                }
            }
            this.closeRaffle(true);
        }
예제 #38
0
        private void buttonSelectDbFolder_Click(object sender, EventArgs e)
        {
            string folder = "";
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();

            if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                folder = folderBrowserDialog.SelectedPath;
            }
            if (Directory.Exists(folder))
            {
                //文件夹及子文件夹下的所有文件的全路径
                string[] files = Directory.GetFiles(folder, "*.db", SearchOption.AllDirectories);
                for (int i = 0; i < files.Length; i++)
                {
                    files[i] = Path.GetFileNameWithoutExtension(files[i]);//只取后缀
                }

                for (int i = 0; i < files.Count(); i++)
                {
                    //建立SQLite连接
                    System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection();
                    System.Data.SQLite.SQLiteConnectionStringBuilder connstr = new System.Data.SQLite.SQLiteConnectionStringBuilder();
                    connstr.DataSource = files[i];
                    //connstr.Password = "******";
                    conn.ConnectionString = connstr.ToString();
                    conn.Open();
                    //执行查询语句
                    string sql = "select id,puid from camdevices";
                    System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand();
                    cmd.CommandText = sql;
                    System.Data.SQLite.SQLiteDataAdapter dataAdapter = new System.Data.SQLite.SQLiteDataAdapter(sql, conn);
                    //填充架构及数据
                    dataAdapter.FillSchema(dataSet1, SchemaType.Source, "camdevices");
                    dataAdapter.Fill(dataSet1, "camdevices");
                    //清空dataGridView数据源
                    if (dataGridViewDb.DataSource != null && dataGridViewDb.DataSource != "")
                    {
                        dataGridViewDb.DataSource = "";
                        dataGridViewDb.Refresh();
                    }
                    //填充dataGridView
                    dataGridViewDb.DataSource = dataSet1.Tables[0];
                    //刷新映射表
                    if (puidmap.ToString() != null && puidmap.ToString() != "")
                    {
                        puidmap.Clear();
                    }
                    for (int j = 0; j < dataSet1.Tables[0].Rows.Count; j++)
                    {
                        puidmap.Add(dataSet1.Tables[0].Rows[i][0], dataSet1.Tables[0].Rows[i][1]);
                    }
                    conn.Close();
                }
            }
        }
예제 #39
0
 public SharedConnectionSource(string connectionString) : base(connectionString)
 {
     Connection = Task.Run(async() =>
     {
         var connection = new System.Data.SQLite.SQLiteConnection(connectionString);
         await connection.OpenAsync();
         OpenConnections = 1;
         return(connection);
     });
 }
예제 #40
0
파일: Program.cs 프로젝트: majorsilence/Dev
        public static void ContribSelectData(UserId id)
        {
            using (var connection = new System.Data.SQLite.SQLiteConnection(cnStr))
            {
                connection.Open();
                var data = connection.Get<Poco.Users>(id);

                System.Diagnostics.Debug.Assert(id.Equals(data.Id));
            }
        }
예제 #41
0
 public bool StopTransaction()
 {
     transaction.Commit();
     transaction.Dispose();
     transaction = null;
     cnn.Close();
     cnn.Dispose();
     cnn = null;
     return(true);
 }
예제 #42
0
        private static void OpenSQLiteDb()
        {
            if (m_dbConnection != null && m_dbConnection.State == System.Data.ConnectionState.Open)
            {
                return;
            }

            m_dbConnection = new System.Data.SQLite.SQLiteConnection("Data Source=MyDatabase.sqlite;Version=3;Password=password;");
            m_dbConnection.Open();
        }
예제 #43
0
파일: Main.cs 프로젝트: cstj/XMusCringle
        public Model.XMusCringleContext GetDBContext()
        {
            if (dbConnString == null)
            {
                return(null);
            }
            var conn = new System.Data.SQLite.SQLiteConnection(dbConnString);

            return(new Model.XMusCringleContext(conn, true));
        }
예제 #44
0
        public void TestMethod1()
        {
            var conn = new System.Data.SQLite.SQLiteConnection("data source=:memory:");

            conn.Open();
            var cmd = conn.CreateCommand();

            cmd.CommandText = "select 1";
            Assert.AreEqual((long)1, cmd.ExecuteScalar());
        }
예제 #45
0
        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");
        }
예제 #46
0
        public void TestCreateBinCentricTables2()
        {
            DataReaderTests.DataReaderTests.PrintMethodName(System.Reflection.MethodBase.GetCurrentMethod());

            var fiSource = new FileInfo(FileRefs.BinCentricTest1);

            if (!fiSource.Exists)
            {
                return;
            }

            var fiTarget = DuplicateUIMF(fiSource, "_BinCentric2");

            if (fiTarget == null)
            {
                return;
            }

            using (var uimfReader = new DataReader(fiTarget.FullName))
            {
                // Note: providing true for parseViaFramework as a workaround for reading SqLite files located on a remote UNC share or in readonly folders
                var connectionString = "Data Source = " + fiTarget.FullName;
                using (var dbConnection = new System.Data.SQLite.SQLiteConnection(connectionString, true))
                {
                    dbConnection.Open();

                    using (var dbCommand = dbConnection.CreateCommand())
                    {
                        dbCommand.CommandText = "PRAGMA synchronous=0;BEGIN TRANSACTION;";
                        dbCommand.ExecuteNonQuery();
                    }

                    var binCentricTableCreator = new BinCentricTableCreation();

                    // Attach the events
                    binCentricTableCreator.OnProgress += BinCentricTableCreator_ProgressEvent;
                    binCentricTableCreator.Message    += BinCentricTableCreator_MessageEvent;

                    mLastProgressUpdateTime  = DateTime.UtcNow;
                    mLastProgressMessageTime = DateTime.UtcNow;

                    binCentricTableCreator.CreateBinCentricTable(dbConnection, uimfReader, ".");

                    using (var dbCommand = dbConnection.CreateCommand())
                    {
                        dbCommand.CommandText = "END TRANSACTION;PRAGMA synchronous=1;";
                        dbCommand.ExecuteNonQuery();
                    }

                    dbConnection.Close();
                }
            }

            Console.WriteLine("Added bin centric tables to " + fiTarget.FullName);
        }
 public override void WithConnection(Action <System.Data.SQLite.SQLiteConnection> action)
 {
     using (var connection = new System.Data.SQLite.SQLiteConnection(connectionString))
     {
         connection.Open();
         OpenConnections++;
         action(connection);
         connection.Close();
         OpenConnections--;
     }
 }
예제 #48
0
파일: Program.cs 프로젝트: majorsilence/Dev
        public static void SelectData(UserId id)
        {
            using (var connection = new System.Data.SQLite.SQLiteConnection(cnStr))
            {
                connection.Open();
                var data = connection.Query<Poco.Users>("SELECT * FROM Users WHERE Id = @Id",
                    new  { Id = id }).FirstOrDefault();

                System.Diagnostics.Debug.Assert(id.Equals(data.Id));
            }
        }
예제 #49
0
        SQLiteConection(System.String ConnectionString)
        {
            var Connection = new System.Data.SQLite.SQLiteConnection(ConnectionString);

            try {
                Connection.Open();
                return(Connection);
            } catch {
                return(null);
            }
        }
예제 #50
0
        private void DataGrid_Initialized(object sender, System.EventArgs e)
        {
            connection = new System.Data.SQLite.SQLiteConnection("Data source=" + System.Environment.CurrentDirectory.ToString() + "\\ToDoAny.sqlite;Version=3;");
            dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("SELECT * FROM priorities", connection);
            dataSet = new System.Data.DataSet();

            dataAdapter.TableMappings.Add("priorities", "priorities");
            var commandBuilder = new System.Data.SQLite.SQLiteCommandBuilder(dataAdapter);
            
            dataAdapter.Fill(dataSet, "priorities");

            SourceDataTable = dataSet.Tables["priorities"];
        }
예제 #51
0
		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();
			}
		}
예제 #52
0
 private Connection()
 {
     if (!System.IO.File.Exists(DB_FILE))
     {
         System.Data.SQLite.SQLiteConnection.CreateFile(DB_FILE);
     }
     
     sqliteConnection = new System.Data.SQLite.SQLiteConnection($"Data Source={DB_FILE};Version=3;Password={PASSWORD};");
     sqliteConnection.Open();
     var sql = "CREATE TABLE torrents (tag VARCHAR(20), url VARCHAR(255), name VARCHAR(255), added DATETIME)";
     var command = new System.Data.SQLite.SQLiteCommand(sql, sqliteConnection);
     command.ExecuteNonQuery();
 }
예제 #53
0
        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 = "";
                }
            }
        }
예제 #54
0
 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();
         }
     }
 }
예제 #55
0
파일: DataBase.cs 프로젝트: HaoCherHong/HAP
        public DataBase()
        {
            string dbPath = @"Database.db";

            if (!System.IO.File.Exists(dbPath))
                System.IO.File.Copy("Database_New.db", dbPath, false);

            sqlConnection = new System.Data.SQLite.SQLiteConnection( "Data Source=" +  dbPath);
            sqlCommand = new System.Data.SQLite.SQLiteCommand(sqlConnection);

            sqlConnection.Open();

            VersionUpdate();
        }
예제 #56
0
파일: Program.cs 프로젝트: krk/MiniProfiler
        /// <summary>
        /// Returns an open connection that will have its queries profiled.
        /// </summary>
        /// <returns>the database connection abstraction</returns>
        public static DbConnection GetConnection()
        {
            DbConnection cnn = new System.Data.SQLite.SQLiteConnection("Data Source=:memory:");

            // to get profiling times, we have to wrap whatever connection we're using in a ProfiledDbConnection
            // when MiniProfiler.Current is null, this connection will not record any database timings
            if (MiniProfiler.Current != null)
            {
                cnn = new StackExchange.Profiling.Data.ProfiledDbConnection(cnn, MiniProfiler.Current);
            }

            cnn.Open();
            return cnn;
        }
예제 #57
0
파일: FormBase.cs 프로젝트: spox/irisim
 private void InitializeDatabase()
 {
     try{
         this.dbconn = new SQLiteConnection("Data Source=IrisIM.db;FailIfMissing=True;Version=3");
         this.dbconn.Open();
     }catch{
         this.dbconn = new SQLiteConnection("Data Source=IrisIM.db;Version=3");
         this.dbconn.Open();
         try{
             CreateDatabase();
         }catch(Exception e){
             throw new System.Exception("Failed to initialize storage: " + e.ToString());
         }
     }
 }
예제 #58
0
        public override void EnsureSharedConnectionConfigured()
        {
            if (Connection != null) return;

            lock (_syncRoot)
            {

            #if DNXCORE50
                Connection = new Microsoft.Data.Sqlite.SqliteConnection(ConnectionString);
            #else
                Connection = new System.Data.SQLite.SQLiteConnection(ConnectionString);
            #endif
                Connection.Open();
            }
        }
예제 #59
0
        public Task(long id, MainWindow parent)
        {
            this.parent = parent;

            IsDirty = false;
            this.id = id;
            connection = new System.Data.SQLite.SQLiteConnection("Data source=" + System.Environment.CurrentDirectory.ToString() + "\\ToDoAny.sqlite;Version=3;");

            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;

            IsLoading = true;
            InitializeComponent();
            LoadData();
            IsLoading = false;
        }
예제 #60
-1
        private void Rptpordonador_Load(object sender, EventArgs e)
        {
            CrystalReport2 objRpt = new CrystalReport2();
            string appPath = Path.GetDirectoryName(Application.ExecutablePath);
            String ConnStr = @"Data Source=" + appPath + @"\dbcar.s3db ;Version=3;";

            System.Data.SQLite.SQLiteConnection myConnection = new System.Data.SQLite.SQLiteConnection(ConnStr);

            String Query1 = "SELECT * FROM Donaciones Where Nombre = '"+nombre1+"' AND Edad = '"+edad1+"'";

            System.Data.SQLite.SQLiteDataAdapter adapter = new System.Data.SQLite.SQLiteDataAdapter(Query1, ConnStr);

            DataSet Ds = new DataSet();

            // here my_dt is the name of the DataTable which we
            // created in the designer view.
            adapter.Fill(Ds, "my_dt");

            // Setting data source of our report object
            objRpt.SetDataSource(Ds);

            // Binding the crystalReportViewer with our report object.
            this.crystalReportViewer1.ReportSource = objRpt;

            objRpt.Refresh();
        }