PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Typed Dataset - Basic Question
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Typed Dataset - Basic Question
![]() |
Typed Dataset - Basic Question |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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 > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
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 > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

