I'm assuming from the items in the list that you have populated that list from data in your database. So one of the ways is to use SQL to perform the various INSERT (add), UPDATE (edit) and DELETE tasks. This will require an understanding of Structured Query Language. The basics of performing any of the 3 is a few simple lines of code. 'Instantiate a connection object
Dim con as New OledbConnection ("connection string to your database")
'Create a string to hold your SQL command
Dim sSQL as String = "INSERT INTO myTable (Field1, Field2) VALUES ('Value1', 'Value2')"
'This example would insert a new row into a table in your database named myTable and in that row, the columns named Field1 and Field2 would be populated with the words Value1 and Value2 respectively.
'To execute this statement, we need to do 3 things. 1. Build a command, 2. Open the connection and 3. Execute that command
'Instantiate a command object and pass it two arguments, The statement and the connection.
Dim cmd As New OledbCommand(sSQL, con)
'Open the connection
con.Open
'Execute the command
cmd.ExecuteNonQuery
con.Close To minimize confusion, as I don't know your level of expertise, I have left out any Try...Catch error handling which I recommend using. Just wanting to keep this simple Now with that code above, you can perform the other 2 commands (update and delete) just by putting the proper SQL statement in the sSQL string. All the other code will work for any of those 3 commands. Keep in mind that the code above assumes that you have also imported the System.Data.OleDb namespace.
|