Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# - Add and Update Records
Message
From
14/04/2008 09:19:07
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
To
13/04/2008 19:29:47
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01309187
Message ID:
01310367
Views:
41
>>>>Tim & Bonnie:
>>>>
>>>>I am sure that I'm totally lost here, and I'm not sure that I'm communicating the problem clearly.
>>>>
>>>>I created a simple project with a Test DB and a Customers table and called the project Typed_DS_Example.
>>>>There is a simple Typed Dataset called DSCustomers in the project. The code loads it from the SQL Customers table. The project is here:
>>>>http://www.geocities.com/kevin.marois/typed_ds/typed_ds_example.zip
>>>>The DB is in the Data folder.
>>>>
>>>>
>>>>Please see these 2 pics:
>>>>
>>>>In the first, you can see that there is an object in the Visualizer called 'DSCustomers'. The structure
>>>>is correct, but there is no data.
>>>>http://www.geocities.com/kevin.marois/typed_ds/visualizer1.jpg
>>>>
>>>>
>>>>In the second, you can see that there is another object in the Visualizer called 'Customers'. The structure is correct, and there is data.
>>>>http://www.geocities.com/kevin.marois/typed_ds/visualizer2.jpg
>>>>
>>>>Now I don't know if this is what is supposed to be happening. I have no experience at all using a
>>>>typed dataset. If this is not correct, then can you show me what's wrong? If it IS correct, the how
>>>>do I use this dataset to Add, Edit and Delete a customer?

>>>>
>>>>Signed, Frustrated In California :)
>>>>
>>>
>>>Think of it like this:
>>>
>>>DataSets (DataBases) Contain Tables
>>>Tables Contain Rows (Records)
>>>Records Contain Columns (Fields)
>>>
>>>>>how do I use this dataset to Add, Edit and Delete a customer?
>>>
>>>Something like this:
>>>
>>>
>>>DSCustomer ds  = new DSCustomer();
>>>DSCustomer.CustomersDataTable tbl = ds.Customers;
>>>DSCustomer.CustomersRow row = ds.Customers.NewCustomersRow();
>>>
>>>//Add
>>>tbl.Rows.Add(row);
>>>
>>>//Edit
>>>row.CustomerName = "";
>>>
>>>//Delete
>>>row.Delete();
>>>
>>>
>>>also: http://msdn2.microsoft.com/en-us/library/ms171928(VS.80).aspx
>>
>>
>>This STILL has not answered my question. Why do I see 2 objects in the DataSet Visualizer? What are these objects?
>
>One is the >>>Tim & Bonnie:
>>>>
>>>>I am sure that I'm totally lost here, and I'm not sure that I'm communicating the problem clearly.
>>>>
>>>>I created a simple project with a Test DB and a Customers table and called the project Typed_DS_Example.
>>>>There is a simple Typed Dataset called DSCustomers in the project. The code loads it from the SQL Customers table. The project is here:
>>>>http://www.geocities.com/kevin.marois/typed_ds/typed_ds_example.zip
>>>>The DB is in the Data folder.
>>>>
>>>>
>>>>Please see these 2 pics:
>>>>
>>>>In the first, you can see that there is an object in the Visualizer called 'DSCustomers'. The structure
>>>>is correct, but there is no data.
>>>>http://www.geocities.com/kevin.marois/typed_ds/visualizer1.jpg
>>>>
>>>>
>>>>In the second, you can see that there is another object in the Visualizer called 'Customers'. The structure is correct, and there is data.
>>>>http://www.geocities.com/kevin.marois/typed_ds/visualizer2.jpg
>>>>
>>>>Now I don't know if this is what is supposed to be happening. I have no experience at all using a
>>>>typed dataset. If this is not correct, then can you show me what's wrong? If it IS correct, the how
>>>>do I use this dataset to Add, Edit and Delete a customer?
>>>>
>>>>Signed, Frustrated In California :)
>>>>
>>>
>>>Think of it like this:
>>>
>>>DataSets (DataBases) Contain Tables
>>>Tables Contain Rows (Records)
>>>Records Contain Columns (Fields)
>>>
>>>>>how do I use this dataset to Add, Edit and Delete a customer?
>>>
>>>Something like this:
>>>
>>>
>>>DSCustomer ds  = new DSCustomer();
>>>DSCustomer.CustomersDataTable tbl = ds.Customers;
>>>DSCustomer.CustomersRow row = ds.Customers.NewCustomersRow();
>>>
>>>//Add
>>>tbl.Rows.Add(row);
>>>
>>>//Edit
>>>row.CustomerName = "";
>>>
>>>//Delete
>>>row.Delete();
>>>
>>>
>>>also: http://msdn2.microsoft.com/en-us/library/ms171928(VS.80).aspx
>>
>>
>>This STILL has not answered my question. Why do I see 2 objects in the DataSet Visualizer? What are these objects?
>
>They are tables in the dataset.
>
>One is the typed DSCustomers table you created in your dataset the other is the Customers table you created when you executed this command:
>
>oDataAdapter.Fill(oDataSet, "Customers")
>
>instead of this one which would have filled the DSCustomers table:
>
>oDataAdapter.Fill(oDataSet.DSCustomers);

Good Catch John,

I thought I had mentioned earlier about naming the table he created in the dataset the same but didn't think about when he called the fill for it also to be the same.

Kevin, I would recommend you name the table in your dataset different as ds prefix would suggest it is the DataSet itself. A DataSet can have multiple tables and is the container for tables.
DataSet dsCustomers
DataTable Customers
oDataAdapter.Fill(dsCustomers, Customers);

Tim
Timothy Bryan
Previous
Reply
Map
View

Click here to load this message in the networking platform