Click to See Complete Forum and Search --> : update database through datagridview


prasad_oct12
July 10th, 2009, 01:05 AM
Hello Friends,
I am getting a problem to update the database from datagridview row.
I am using the following code

private void showButton_Click(object sender, EventArgs e)
{
con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\MoneyData.mdb");
String query = "SELECT * FROM Categories";
da = new OleDbDataAdapter(query, con);
OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];

con.Close();

}

private void UpdateButton_Click(object sender, EventArgs e)
{
da.Update(ds);
}

if i run the code
i am getting the following error
"Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information."
Please help me...
thank you

memeloo
July 11th, 2009, 06:00 AM
have your table a primary key?

prasad_oct12
July 11th, 2009, 12:34 PM
no , but foreign key is there for one column, but i am not updating that column....