Reputation: 4848
I have a dataset (DataSet1) defined in the dataset screen in VS2010. It contains a datatable (DataTable1):
Shouldn't I be able to access this datatable now in my program, like this?:
DataTable1.Rows.Add("Mark","123 Anystreet","555-512-2333","[email protected]")
When I try to do the above code, the editor acts like it has no idea what DataTable1 is, even though I have created it in the dataset screen. I don't want to bind the datatable to a datasource, since the data will be provided programatically (this is just a test program).
Any ideas?
Thanks!
Upvotes: 0
Views: 1104
Reputation: 29226
have you declared an instance of the dataset? just creating the dataset in the editor is not enough. basically all you have done is designed what the dataset "looks" like. the tables and the columns in those tables, along with the data type (and other assorted properties) of each column.
typically, you create an instance of your (typed) dataset
somewhere in your code...
MyDataSet ds = new MyDataSet();
then, add your rows to the instance of the table....
DataTable1.Rows.Add("Mark","123 Anystreet","555-512-2333","[email protected]")
Upvotes: 1