Clearing Table and Adding Rows to It

vendiddy

Well-known member
Joined
May 14, 2006
Messages
64
Programming Experience
1-3
Let us say that that I have a Table in an Access database that is called MyItems:
VB.NET:
+--------------+------------+------------+
| Name (String)| X (Number) | Y (Number) |
+--------------+------------+------------+
And that I have a class called TheItem:
VB.NET:
Class TheItem
   Sub New(Name as String, X as Integer, Y as Integer)
   Property Name as String
   Property X as Integer
   Property Y as Integer
End Class

If I have an array of TheItem objects called MyItemArray()...

How would I be able to
  • Delete all of the existing rows in the table MyItems?
  • Create a new row in the table MyItems for each TheItem object in MyItemArray?

Thanks. :)
 
Last edited:
Let us say that that I have a Table in an Access database that is called MyItems:
VB.NET:
+--------------+------------+------------+
| Name (String)| X (Number) | Y (Number) |
+--------------+------------+------------+
And that I have a class called TheItem:
VB.NET:
Class TheItem
   Sub New(Name as String, X as Integer, Y as Integer)
   Property Name as String
   Property X as Integer
   Property Y as Integer
End Class

If I have an array of TheItem objects called MyItemArray()...

How would I be able to
  • Delete all of the existing rows in the table MyItems?
  • Create a new row in the table MyItems for each TheItem object in MyItemArray?

Thanks. :)

See the DW2 link in my signature, section on creating a simple data app. Then see how to add a new query to the tableadapter, and add:
DELETE FROM myTable

Run that to dump your stuff

Add new rows to your local datatable and then call Update() to persist them to the database.

None of this will make much sense until you read the link! Read it now!
 
Back
Top