Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can anyone give me an example how to use datagrid that will reflect its changes to your mysql database....

i have tried doing the following.

Create the DataGridView (I let .NET create the BindingSource stuff)
Entered the following code into my 'Save' button click event,but it gave me an error
(Update requires a valid UpdateCommand when passed DataRow collection with modified rows.)

VB
Me.Validate()
Me.StgCustomerBindingSource.EndEdit()        
Me.Stg_CustomerTableAdapter.Update(Me.AdventureWorksDataSet.Tables("stg_Customer"))


please.your reply will be be a very big help
Posted
Updated 29-Sep-11 6:29am
v2

Specify the update command for data adapter as it seems the datagrid is not populated with all the data from the data table. Therefore it needs to know the exact updatecommand to save the data. Here is the link which can help you:

http://msdn.microsoft.com/en-us/library/33y2221y.aspx[^]
 
Share this answer
 
v2
Comments
JMAM 29-Sep-11 12:49pm    
Can you please give me a more specifc answer i'm a bit confused because i am new in vb.net
Pradeep Shukla 29-Sep-11 12:51pm    
Updated the solution...have a look
download the demo project from.

http://www.codeproject.com/KB/database/DataGridView2Db.aspx
 
Share this answer
 
Comments
JMAM 30-Sep-11 8:10am    
Hi Bhatt Aniruddh,

i tried to download it from the above link and change its binding source to my own database source...data greed works great showing all the contents of my database however and still, changes that was made from the datagrid during runtime doesnt affect my database...btw i am using mysql and visual basic 2008

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900