Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Error getting SQLite to datagridview

$
0
0

Hi folks,

I getting an error when i try to get database members to datagridview. The error i get is unhandled exception 'source' more detail is not there.

The method i use:

public int LaadData(DataGridView dgv)
        {

            string SQL = "SELECT * FROM Persoon";
            using (var dt = new DataTable())
            {

                using (SQLiteCommand cmd = new SQLiteCommand())
                {
                    //cmd.Connection = con;
                    //cmd.CommandText = SQL;
                    SQLiteDataAdapter da = new SQLiteDataAdapter(SQL, con);
                    da.Fill(dt);
                }
                dgv.DataSource = dt; // error
            }

            
            con.Close();
            return dgv.Rows.Count;
        }

Hopefully another knows the correct answer.

Rinaldo


Greetings from Amsterdam the Netherlands


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>