nicedreams Posted January 29, 2004 Share Posted January 29, 2004 I am trying to make a datagrid in a vb.net windows form that you can change the info in the cells. Once the cell data is changed, I want to change the info in a mysql database. Thanks in advance. Link to comment https://www.neowin.net/forum/topic/136288-vbnet-datagrid-editing/ Share on other sites More sharing options...
0 idkfa Posted January 29, 2004 Share Posted January 29, 2004 I don't have time to explain this in detail, but here's the basics... 1. Right click your datagrid and go to 'Property Builder'. Go to the 'Columns' section. 2. Add an 'Edit, Update and Cancel' column from the 'Button Column' node. Click OK. 3. In the code behind, select the DataGrid from the drop down list at the top left, then select the 'Edit Command' from the drop down list at the top right of the page. This will create the subroutine that is called when you click the 'Edit' button on the datagrid. 4. You need to do this for the 'Update Command' as well. In this sub (which is for the 'Update' button) you'll need to add code to set the new values in the dataset and then update the dataset and re-bind the datagrid. 5. You should also create a subroutine for the cancel button. The code for the edit button is something like: Datagrid1.EditItemIndex = e.Item.ItemIndex DataGrid1.DataBind The code for the cancel button is something like: DataGrid1.EditItemIndex = -1 DataGrid1.DataBind hope that gives you something to work with Link to comment https://www.neowin.net/forum/topic/136288-vbnet-datagrid-editing/#findComment-1663255 Share on other sites More sharing options...
0 nicedreams Posted January 29, 2004 Author Share Posted January 29, 2004 Thanks for the reply. I have done that for asp.net already. I can't do it in regular VB the datagrid is set up differently. I'm using VisualStudio 2002. There isn't a property builer for it like there is in asp.net. Link to comment https://www.neowin.net/forum/topic/136288-vbnet-datagrid-editing/#findComment-1665769 Share on other sites More sharing options...
0 Bender Posted January 29, 2004 Share Posted January 29, 2004 use the dataform wizard, all you need to know you can get from the code it produces. Link to comment https://www.neowin.net/forum/topic/136288-vbnet-datagrid-editing/#findComment-1667147 Share on other sites More sharing options...
0 nicedreams Posted January 30, 2004 Author Share Posted January 30, 2004 I tried using the wizard, but it doesn't work for MYSQL databases (I can't afford SQL server). I found the following link http://msdn.microsoft.com/library/default....pterDataSet.asp and tried to adapt it to mysql, but I can't get it to work. Here is my code: Protected Sub cmdUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdUpdate.Click myDataSet.AcceptChanges() 'when I don't have this, it throws a system error with no description darAdapter.UpdateCommand = New MySQLCommand("UPDATE RequestedInventoryItems SET Quantity = @Quantity" & _ "WHERE ID = @ID", conMysql) 'conMysql is the MySQLConnection darAdapter.UpdateCommand.Parameters.Add("@QuantityMyMySQLDbType.Int24, "Quantity") Dim workParm As MySQLParameter = darAdapter.UpdateCommand.Parameters.Add("@IDMyMySQLDbType.Int24) workParm.SourceColumn = "ID" workParm.SourceVersion = DataRowVersion.Original darAdapter.Update(myDataSet.Tables("Inventory")) End Sub PLEASE HELP! :wacko: Link to comment https://www.neowin.net/forum/topic/136288-vbnet-datagrid-editing/#findComment-1670599 Share on other sites More sharing options...
Question
nicedreams
I am trying to make a datagrid in a vb.net windows form that you can change the info in the cells. Once the cell data is changed, I want to change the info in a mysql database. Thanks in advance.
Link to comment
https://www.neowin.net/forum/topic/136288-vbnet-datagrid-editing/Share on other sites
4 answers to this question
Recommended Posts