Reputation: 58
Recently I've been trying to mess around with datasets and datatables and I've cam by an issue that I have been trying to figure out for about 2 hours and I've also shredded the Google search button.
Dim newCustomersRow As DataRow = DataSet1.Tables("Customers").NewRow()
newCustomersRow("CustomerID") = "ALFKI"
newCustomersRow("CompanyName") = "Alfreds Futterkiste"
DataSet1.Tables("Customers").Rows.Add(newCustomersRow)
Well the issue is not the tables itself since its an untyped dataset with the required tables but I've been getting an error near DataSet1.Tables
.
Error: Error 4 Reference to a non-shared member requires an object reference.
Upvotes: 1
Views: 2333
Reputation: 4938
You must create an instance of your DataSet1
.
For example:
Dim ds1 As New DataSet1
Dim newCustomersRow As DataRow = ds1.Tables("Customers").NewRow()
newCustomersRow("CustomerID") = "ALFKI"
newCustomersRow("CompanyName") = "Alfreds Futterkiste"
ds1.Tables("Customers").Rows.Add(newCustomersRow)
This will create your DataSet1
object reference
Upvotes: 1