Search code examples
c#visual-studiostrongly-typed-datasettyped-dataset

Typed dataset correct usage


If I understand this right, do I have to use the table adapters to get data into my typed data set, I can't just create my strongly typed data-set and have the data autoload? (im also using a .net 3.5 project in VS2012)

for example, I have to do this to get data (If I do it this way, I get data)

 var a = new EvtDataSetTableAdapters.tblFileTableAdapter();
  a.GetData();

versus just doing this, (if I do it this way, I get nothing... and I could understand if its lazy loading...??)

EvtDataSet o = new EvtDataSet();
var r = o.tblFile.Select();

Solution

  • The much maligned, much misunderstood strongly typed dataset! Typically yes you would use a TableAdapter to load the data, and to perform updates. Using the designer you would add parameter queries to the table adapter to support the operations your program requires eg select * from customers where customerid = @customerid

    Call this FillbyCustomerid.

    Then you would pull the data for the selected customer using the TableAdapter by something along the lines of:

    dim ta as new dscustomerstableadapters.customertableadapter
    dim ds as new dsCustomers
    ta.fillbycustomerid (ds.customers, ourid)