| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| C-Sharp Programming Post questions, answers, and comments about C#. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#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 |
|
#2
|
|||
|
|||
|
Re: update database through datagridview
have your table a primary key?
__________________
win7 x86, VS 2008, C++/CLI, C#, .NET 3.5, VB.NET, VBA remeber to give feedback and if you think my response deserves recognition perhaps you may want to click the Rate this post link/button
|
|
#3
|
|||
|
|||
|
Re: update database through datagridview
no , but foreign key is there for one column, but i am not updating that column....
|
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|