If you use a Data Grid View then that's all you need, because it allows the user to add, edit and delete records. displaying one record at a time, then you need to add a bit more code to add or delete records. End Edit() End Using End Sub It shows me the new record but when i close the application , it doesn`t save. If you've got a typed Data Set then you use Table Adapters to retrieve and save data. Use a Table Adapter to retrieve the data and populate a Data Table. You bind your Data Table to a Binding Source and the Binding Source to your controls. Read the last paragraph of my previous post and then ask yourself if that's what your code is doing. You can also call End Edit on the Binding Source in code to commit the new row. Click '---------------------------------------------------------------------------- Using con As New Sql Connection("Data Source=.\SQLEXPRESS; Attach Db Filename=H:\Projects\Windows Application1\Windows Application1\Database1.mdf; Integrated Security=True; Connect Timeout=30; User Instance=True") Me. And after (if this will be solved) that i managed again with your blog (john) to copy form one table to another and now i need to change that code too because i can`t refresh / update it. If you want to create a new row in code then you use the Binding Source like so: The user can then enter the field values via the UI and the row is committed to the underlying Data Table when they navigate away to another record. Database1Data Set1) Dim new Row = Direct Cast(Produse Binding Source. And i have 3-4 columns in that row , how hould i do that , i tried some variants but did not succeed. Abstract: I was recently working on a requirement to perform Update and Delete operations on a WPF Data Grid control (similar to what developers do in a ASP. The WPF Data Grid is an excellent control to bind with collections and provides various events to work with. Now since Salary and Dept No can be updated, on the click event of the ‘Update’ button, the following code is written.I was recently working on a requirement to perform Update and Delete operations on a WPF Data Grid control (similar to what developers do in a ASP. The WPF Data Grid is an excellent control to bind with collections and provides various events to work with. This code changes the columns for ‘Salary’ and ‘Dept No’ in edit mode.
Open() Try Using my Command As New Sql Command("INSERT INTO Produse (Nume , Pret , Cod) VALUES (@Nume, @Pret, @Cod)") my Command.
Using bind variables makes the statement reusable with different input values.
Using bind variables also improves query performance in the database, eliminates the need for special handling of literal quotation marks in the input, and protects against SQL injection attacks.
Once the Framework Element is extracted, by type casting it to the ‘Text Box’ UI element, the value changed in the cell can be read.
Here ‘Salary’ and ‘Dept No’ are changed and updated into the selected ‘Employee’ object.