Typed Dataset - Basic Question

  • Thread starter Thread starter divisortheory
  • Start date Start date
D

divisortheory

I used the Designer to generate Typed Dataset classes for every table
in a database I'm using. In one particular table, I use a numeric
Autonumber column as the primary key, 1 text column specifying a
friendly name, and some other miscellaneous columns. Given a string
representing a friendly name, I want to insert a new row if no such row
exists yet, and I want to get the existing row if such a row does
already exist. Then, with either the new row or the existing row, I
want to make some modifications on the row and save it to the database.

What's the most elegant way to do this? I can call .Select() on my
compiler-generated table class passing in the filter column, then check
if there's 0 rows, then add a new one or use the existing row, but my
gut tells me there's a more elegant way involving the adapters that I'm
not seeing. Sorry if this is a basic question, but being my first
experienec with Typed datasets and there's a ton of compiler generated
code that I have yet to fully understand.

Thanks
 
You pretty much have it. Check for the row, and if it's not there,
add a new row. If your dataset is completely populated, you can also
probably use a Find or FindRows function to look for a match. It
will be quicker than Filter.

Robin S.
 
You mean something as

\\\
dim dr as ds.TheTableRow 'check the name I do this forever with
intellicense
If RowExistAlready then
dr = table(0) 'existingRow
Else
dr = Table.NewRow
table.rows.Add(dr)
End if
///

Quickly written in this mssage so watch typos.

Cor
 
Back
Top