0

I'm developing an app with C# and SQLite. My problem is, I need to execute INSERT query and SELECT query at the same time. If I explain with more detail my problem is;

Let's say my database name is myDB,

I'm importing a 1 MB text file to myDB. While this import is processing, is another window (in the same app and using same connection and same database file) can execute a SELECT query?

Thank you for helping!

  • Despite the fact it is possible, you better organize it differently. One cheap solution would be to populate both database and the view (with SELECT from that database, which you make once, when you open window) with INSERT'ed row (you insert it into database and into a view of "another window"). Other solution is to show progress application wide (updated after each operation) and update "another window" less frequently (to example, once in a few seconds). This is assuming no other user is working with the database. Otherwise.. keep thinking =D – Sinatr Jan 08 '14 at 12:53

1 Answers1

0

Ok, why you need select? you will get something of the insert and put in another table? Or the program need keep run like nothing are running?

if you need select to put in another table, you can use it: select * from table order by cod desc limit 1;

or, if you need keep running, you will need a thread, its a example:

onLoad()
{
Thread t = new Thread(new ThreadStart(t_trigger));
            t.Start();
}


private void t_trigger()
{
 table_insert(string d)
}

private delegate void delegate_table_insert(string d);

private void table_insert(string d)
        {
            if (InvokeRequired)
            {
                try
                {
                    Invoke(new delegate_table_insert(table_insert), d);
                }

                catch (Exception ex)
                {
                    //MessageBox.Show(ex.Message);
                }
            }
            else
            {
                try
                {
                    // here run the code
                }

                catch (Exception ex)
                {
                    //MessageBox.Show(ex.Message);
                }
            }