PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Typed Dataset - Basic Question

Reply

Typed Dataset - Basic Question

 
Thread Tools Rate Thread
Old 04-01-2007, 06:34 AM   #1
divisortheory
Guest
 
Posts: n/a
Default Typed Dataset - Basic Question


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

  Reply With Quote
Old 04-01-2007, 06:42 AM   #2
RobinS
Guest
 
Posts: n/a
Default Re: Typed Dataset - Basic Question

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.
------------------------
"divisortheory" <divisortheory@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
>



  Reply With Quote
Old 05-01-2007, 05:52 AM   #3
Cor Ligthert [MVP]
Guest
 
Posts: n/a
Default Re: Typed Dataset - Basic Question

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


"divisortheory" <divisortheory@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
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off