Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# Typed DataSet Questions
Message
 
To
20/04/2008 12:48:13
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01310405
Message ID:
01312003
Views:
27
Well, I went out and bought another ADO.Net book. I had already bought one, but it wasn't that good. I figured that with all the questions I still have, it's time to get back into a book and reread all of this again.


>Hi Kevin,
>
>
>DSCustomer oDataSet = new DSCustomer();
>oDataAdapter.Fill(oDataSet, "DSCustomer");

>I doubt if your Table is called "DSCustomer" and if it is, you should change it to just plain old "Customer", in which case your .Fill could be:
>
>
>oDataAdapter.Fill(oDataSet, "Customer");
>
>
>You can also utilize table mapping (helpful if you're returning more than one table, such as when using a Stored Proc).
>
>
>oDataAdapter.TableMappings.Add("Table", "Customer");
>oDataAdapter.TableMappings.Add("Table1", "MyNextTable");
>oDataAdapter.Fill(oDataSet);
>
>
>We have a lot of this functionality in our "framework" base classes.
>
>>1) What's the syntax for changing the value of a data item in the row?
>
>Q1 has been answered already by John ... he has excellent advice about taking advantage of the typed syntax.
>
>>2) How do I save the changes to the back end?
>
>Q2 has been answered many times already by me ... even one directed to you a couple of weeks ago and I thought you had already got it to work just fine. See Message #1306779 and the replies, etc. associated with it.
>
>>3) Could someone point me to examples of binding the DS to form controls?
>
>Tim has given you one example for setting a DataSource for a ListBox, but complex databound objects (such as ListBoxes and ComboBoxes) actually have two kinds of databinding. One for setting it's data source, and one for binding to the selected items. And, to further confuse the issue, there are two ways (two different syntaxes) to specify databinding for any control and this results in two distinct binding objects.
>
>The problem is that you can't mix and match ... you have to stay consistent throughout the form (and, to be honest, I've found that the first method doesn't always seem to work correctly ... at least in the 1.1 Framework ... maybe it's better in the 2.0 or 3.0 Framework, I don't know because I never switched the way I've been doing it all along ... I always use the second option).
>
>So, in other words, if you bound a DataGrid with the following (and this is the syntax I *don't* recommend):
>
>this.oGrid.DataSource = oDataSet;
>this.oGrid.DataMember = "Customer";
>
>Then you have to use the following syntax with TextBoxes:
>
>this.txtLastName.DataBindings.Add("Text", oDataSet, "Customer.LastName")
>
>
>But if you bound your grid with:
>
>this.oGrid.DataSource = oDataSet.Customer;
>
>Then you use this syntax for TextBoxes:
>
>this.txtLastName.DataBindings.Add("Text", oDataSet.Customer, "LastName")
>
>
>Notice that I am using the Typed DataSet syntax, but this applies to non-typed DataSets as well.
>
>~~Bonnie
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform