Home All Groups Group Topic Archive Search About

Typed Dataset - Basic Question

Author
4 Jan 2007 6:34 AM
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

Author
4 Jan 2007 6:42 AM
RobinS
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.
------------------------
Show quote
"divisortheory" <divisorthe***@gmail.com> wrote in message
news:1167892493.733540.179770@i80g2000cwc.googlegroups.com...
>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
>
Author
5 Jan 2007 5:52 AM
Cor Ligthert [MVP]
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


Show quote
"divisortheory" <divisorthe***@gmail.com> schreef in bericht
news:1167892493.733540.179770@i80g2000cwc.googlegroups.com...
>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
>

AddThis Social Bookmark Button