Understanding DataGridView.DataMember

157 views Asked by At

I am having trouble figuring out how this DataMember should work.

It gives me the error 'Child list for field tbl1 cannot be created.'

I have tried tbl1, table1, text, table1_text etc.

What is the logic behind the DataMember and is it documented anywhere?

How do I selected certain fields to be shown?

string sql = "select * from table1 order by text"; // id, text
DataSet ds = new DataSet("tbl1"); // originally just ()
OdbcDataAdapter adapter = new OdbcDataAdapter(sql, connection);
adapter.Fill(ds);
connection.Close();
dataGridView1.AutoGenerateColumns = true;
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "tbl1";  // fails here

Update: The answer is

dataGridView1.DataMember = "Table";

The next question is why? What is the format and naming here? Where is "Table" defined?

0

There are 0 answers