Well, my question is how do I get connections open with [STAThread] attribute 
on Main method.

-----Original Message-----
From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On 
Behalf Of Kevin Benson
Sent: January-05-17 2:49 PM
To: SQLite mailing list <sqlite-users@mailinglists.sqlite.org>
Subject: Re: [sqlite] new user seeking help

 On Thu, Jan 5, 2017 at 1:26 PM, Chen, Hui <hui.c...@worldreach.com> wrote:

> Hi there,
>
> I just recently started integrating System.Data.SQLite.dll into my 
> project, I started with a very simple winform application.
>
> I have a very simple method to create a connection, txtSqliteFile is 
> textbox for db file location.
> SQLiteConnection GetConnection()
> {
>     string connectionString = "Data Source=" + txtSqliteFile.Text + 
> ";Version=3;datetimeformat=CurrentCulture";
>     SQLiteConnection conn = new SQLiteConnection(connectionString);
>     return conn;
> }
>
> Then in a button handler I have these to open a connection.
>
> SQLiteConnection conn = GetConnection(); conn.Open();
>
> whenever Open method is called, Following exception thrown Attempted 
> to read or write protected memory. This is often an indication that 
> other memory is corrupt.
>
> If I remove [STAThread] attribute from Main, it opens connections 
> without problem, but my OpenFileDialgue blows up, I have to have 
> [STAThread] on Main method.
> SQLite documentation says that I can change the threading model, but 
> doesn't say how this can be achieved in C#. all examples are in C/C++
>
> Can anyone give me a hint?
>

https://richnewman.wordpress.com/2007/04/08/top-level-exception-handling-in-windows-forms-applications-part-1/

--
   --
      --
         --Ô¿Ô--
        K e V i N


>
> Thanks
>
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to