Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

pitwi

@pitwi
About
Posts
7
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • fast directory infos for a lot of files
    P pitwi

    Thanks Richard, thats really great. A little correction to the following line:

    using (SQLiteCommand dbCom = new SQLiteCommand("INSERT INTO Dateien (Pfad, Datei) VALUES ($Pfad, $Datei)"))

    to

    using (SQLiteCommand dbCom = new SQLiteCommand("INSERT INTO Dateien (Pfad, Datei) VALUES ($Pfad, $Datei)", dbConn, dbTrans))

    And now it works perfectly. And wow, it's done in 12 seconds !!! Very impressive !!! THANKS!

    WPF csharp database sqlite wpf help

  • fast directory infos for a lot of files
    P pitwi

    I found an answer myself: Reading all 350,000 files from the HD takes 6.2 minutes (!!!). So the bottleneck is SQLite and I think I have to use SQL transactions to speed up my app.

    WPF csharp database sqlite wpf help

  • fast directory infos for a lot of files
    P pitwi

    I'm writing a WPF (C#) app for my MP3 collection with more then 350,000 files. I'm reading path and filenames directly from the HD and store the infos in a SQLite Database. Because of reorganizationes I have to do that in periodic intervals. But the current code needs 17 hours (!!!) for that. I'm sure there must be a faster way. Does anyone have an idea?

        private void ButtonImport\_Click(object sender, RoutedEventArgs e)
        {
            // Import
    
            string initdir = @"H:\\mp3\\";
    
            Cursor cu = this.Cursor;
            this.Cursor = Cursors.Wait;
            string errtxt = "";
            // delete all existing database entries
            ToolStripStatusLabel1.Text = "deleting ..."
            try
            {
                SQLiteCommand dbCom = new SQLiteCommand("DELETE FROM Dateien", dbConn);
                dbCom.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "delete error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            sPfad = initdir;
            // import
            DateTime t1 = DateTime.Now;
            int z = 0;
            loopDir(sPfad);
            DateTime t2 = DateTime.Now;
            txt = "";
            txt += z.ToString() + " files saved in ";
            txt += ((t2 - t1).TotalSeconds / 60).ToString("0.0") + " min.";
            txt += errtxt != "" ? Environment.NewLine + Environment.NewLine + errtxt : "";
            this.Cursor = cu;
            MessageBox.Show(txt, "Import", MessageBoxButton.OK, MessageBoxImage.Information);
        }
    
    
        private void loopDir(string strPath)
        {
            // read directories and files
            string dn = "";
            DirectoryInfo ofs = new DirectoryInfo(strPath);
            bool f = false;
            int n = 0;
            try
            {
                n = ofs.GetDirectories().Length;
            }
            catch (Exception ex)
            {
                f = true;
                errtxt += ex.Message + Environment.NewLine;
            }
            if (f == false)
            {
                foreach (DirectoryInfo d in ofs.GetDirectories())
                {
                    dn = strPath + "\\\\" + d.Name;
                    dn = dn.Replace("\\\\\\\\", "\\\\");
                    loopDir(dn);  // recursive call
                }
                // file loop
                bool ok = false;
    
    WPF csharp database sqlite wpf help

  • ? where should I go ?
    P pitwi

    ... and what about Electron?

    Design and Architecture csharp java javascript python php

  • ? where should I go ?
    P pitwi

    Hi! I want to upgrade my programming skills but don't know where to go. Programming is an important hobby for me and I also made some tools for my company and for me to facilitate my work and my other hobbies. For decades I used Visual Basic in MS Visual Studio. The last years a also tried HTML, CSS, JS, PHP, Python, SQL. And a view months ago I changed from Visual Basic to C#. And I ask myself if I should leave MS. What I need and want: - Nice graphical user interfaces. - At the moment preferred Windows desktop apps. Web apps only if they also can handle local data. - Maybe Linux and/or mobiles in the farer future, never ever Apple. - Local and server databases. (XML, SQLite; MySQL, ...) - Graphics (photos, charts, simple games, ...). What I think of different tools and languages: - Visual Studio WinForms: Old, outdated but still not bad. - Visual Studio WPF and UWP: Nice but also outdated, MS stopped them. - Visual Studio ASP.NET: I never tried it. - JS: Great but not for local data(bases) und code is readable for everyone. - Python: Great but no nice GUIs and I don't know if the compiler is good. - Java: I never tried it but I think it can do everything. What about GUIs? How difficult to learn? So what do you think? What are your experiences? What can you recommend? Thanks

    Design and Architecture csharp java javascript python php

  • editing a WPF DataGrid
    P pitwi

    Hi! I've searched for a couple of hours here and in other forums and at GitHub but couldn't find an answer. I have a XML file and can read it in a DataTable and show that in a DataGrid. But I want to edit cells/values in the DataGrid and write the corrected values back to the XML file. It's easy for me to write the corrections to the DataTable and back to the XML file but how can I do the edit in the DataGrid ??? What I have so far with VisualStudio 2022:

    using ...

    namespace Gewicht
    {
    /// /// Interaction logic for MainWindow.xaml
    ///
    public partial class MainWindow : Window
    {
    public string[] dbFile = { @"H:\Daten\C#WPF\Gewicht\GewichtDaten.xml", @"H:\Daten\C#WPF\Gewicht\GewichtDaten.xsd" };
    public DataTable dbDataTbl = new DataTable();

        public MainWindow()
        {
            InitializeComponent();
        }
    
        private void Window\_Loaded(object sender, RoutedEventArgs e)
        {
            if (!System.IO.File.Exists(dbFile\[0\]) | !System.IO.File.Exists(dbFile\[1\]))
                {
                SystemSounds.Beep.Play();
                MessageBox.Show("Die Datei" + Environment.NewLine + "   " + dbFile\[0\] + Environment.NewLine + "und/oder" + Environment.NewLine + "   " + dbFile\[1\] + Environment.NewLine + "fehlt." + Environment.NewLine + "Das Programm wird beendet.", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
                Environment.Exit(0);
            }
            DataGrid1.CanUserAddRows = false;
            DataGrid1.CanUserDeleteRows = false;
            OpenData();
        }
    
    
        private void DataGrid1\_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            // edit
            // ... ???????????????????????? ...
        }
    
    
        private void OpenData()
        {
            // open data
    
            dbDataTbl.Columns.Clear();
            dbDataTbl.Rows.Clear();
            dbDataTbl = new DataTable("ich");
            dbDataTbl.ReadXmlSchema(dbFile\[1\]);
            dbDataTbl.ReadXml(dbFile\[0\]);
            // DataGrid
            DataSet dataSet = new DataSet();
            dataSet.ReadXml(dbFile\[0\]);
            DataView dataView = new DataView(dataSet.Tables\[0\]);
            DataGrid1.ItemsSource = dataView;
            // format columns
            Style style = new Style();               // creates object of style class   
            style.TargetType = typeof(DataGridCell); // sets target type as Data
    
    WPF csharp wpf question xml help

  • sql query problem
    P pitwi

    I have the following query in my own photo database:

    select distinct left(Nr, 8) as Date, Ort from Fotos where Typ='D' order by left(Nr, 8) desc, Ort

    Where Nr is a unique string with date + a hyphen + a sequential number in the form yyyymmdd-xxx. Ort is a string, the location of the photo. This works fine so far and I get a list like this:

    20220717 Lindabrunn, Symposion
    20220717 Feistritzsattel
    20220717 Pernitz, Schärfthal
    20220715 Mannswörth
    20220715 Wienerbergteich
    20220715 Zentralfriedhof
    20220712 V
    20220710 Himberg

    But what I really want is the first Nr for a date and a location like this:

    20220717-001 Lindabrunn, Symposion
    20220717-045 Feistritzsattel
    20220717-103 Pernitz, Schärfthal
    20220715-001 Mannswörth
    20220715-009 Wienerbergteich
    20220715-033 Zentralfriedhof
    20220712-001 V
    20220710-001 Himberg

    Can someone help? Thanks

    Database database help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups