Hello, I created an OLEDB database with relations, it works fine. I tried converting it to SQLite however I'm getting empty datagridview.
CSHARP Code:
private void Form1_Load(object sender, EventArgs e) { // Compose the connection string. string connect_string = @"Data Source=Contacts.sqlite; Version=3; FailIfMissing=True; Foreign Keys=True;"; // Create a DataAdapter to load the Addresses table. DaAddresses = new SQLiteDataAdapter( "SELECT * FROM Addresses", connect_string); // Create a DataAdapter to load the Addresses table. DaTestScores = new SQLiteDataAdapter( "SELECT * FROM TestScores", connect_string); // Create and fill the DataSet. StudentDataSet = new DataSet(); DataTable dt = new DataTable("Addresses"); DataTable dt2 = new DataTable("TestScores"); StudentDataSet.Tables.Add(dt); StudentDataSet.Tables.Add(dt2); DaAddresses.Fill(dt); DaTestScores.Fill(dt2); // Define the relationship between the tables. DataRelation data_relation = new DataRelation( "Addresses_TestScores", StudentDataSet.Tables["Addresses"].Columns["ContactID"], StudentDataSet.Tables["TestScores"].Columns["ContactID"]); StudentDataSet.Relations.Add(data_relation); // Bind the DataGrid to the DataSet. dgv.AutoGenerateColumns = true; dgv.DataMember = StudentDataSet.Tables[0].TableName; dgv.Update(); dgv.DataSource = StudentDataSet; }
How can I show data on Datagriview?




Reply With Quote
