|
-
July 10th, 2009, 01:05 AM
#1
update database through datagridview
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
-
July 11th, 2009, 06:00 AM
#2
Re: update database through datagridview
have your table a primary key?
win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming
remeber to give feedback  you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation
private lessons are not an option so please don't ask for help in private, I won't replay
if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know
-
July 11th, 2009, 12:34 PM
#3
Re: update database through datagridview
no , but foreign key is there for one column, but i am not updating that column....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|