views:

35

answers:

1

I've a button on my frmMain that opens up another frmEdit which has a datagridview that displays the following query:

BindingSource bs = new BindingSource();
string sqlqry = "select p_Name from Items where p_Id=" + p_Id;

SqlCeCommand cmd = new SqlCeCommand(sqlqry1, conn);
SqlCeDataReader rdr = cmd.ExecuteReader();
bs.DataSource = rdr;
dataGridView1.DataSource = bs;
this.ShowDialog(parent);

When frmEdit loads up the DataGridView displays the query just fine, but I can't Edit. I tried dgv.BeginEdit(true), but it doesn't work. The EditMode works fine if I used wizard to bind datasources to the dgv, but I need to execute my own customized queries and be able to update them directly.

A: 

You need a bidirectional datasource.

I think you can use SqlCeResultSet instead of a SqlCeDataReader.

leppie
This doesn't enable Edit mode either.
DanSogaard
Well, you have to at least return the PK I guess.
leppie
I don't think I fully understand you here, do you mean I should select the p_Name along with p_Id as well?. I tried this too.
DanSogaard