Home All Groups Group Topic Archive Search About
Author
27 Jan 2007 9:36 AM
Neil
Hi,

I'm wondering if it's possible to regenerate the increment id's in an
AutoIncrement Column?

My situation is this...I have a client application that is recieving a
several DataTables from a service. The DataTables contain an auto increment
column which is guaranteed to be unique within that table but I need to merge
the tables together to create a new table and still have a unique column.

Orignally I was taking the first table as a base and then adding new rows to
this for the other tables using LoadDataRow since the structure will always
be the same.

Since the format of each table is the same I'm using
LoadDataRow(myRowToAdd). I have tried creating a new AutoIncrementColumn and
LoadingDataRow but this doesn't work, I end up with NULLS in the new Column
and of course non unique values in the existing.

So I guess my question is what is the best way to create this new
autoincrement column? I'm hoping I don't have to loop through the datatables
that come in because I will be recieving updates to all this data and think
this could be quite slow.

Any help appreciated.

Thanks

Author
28 Jan 2007 10:29 AM
Cor Ligthert [MVP]
Neil,

Therefore try to forget in this century the simple autoincrement id and use
the Global Unique Identifier (GUID) in SQL the Unique Identifier to make
ID's. You know, you are not the first with the problems you are describing.

Just my thought,

Cor

Show quote
"Neil" <N***@discussions.microsoft.com> schreef in bericht
news:B5DB0625-3D92-426F-9A0F-8B310F322697@microsoft.com...
> Hi,
>
> I'm wondering if it's possible to regenerate the increment id's in an
> AutoIncrement Column?
>
> My situation is this...I have a client application that is recieving a
> several DataTables from a service. The DataTables contain an auto
> increment
> column which is guaranteed to be unique within that table but I need to
> merge
> the tables together to create a new table and still have a unique column.
>
> Orignally I was taking the first table as a base and then adding new rows
> to
> this for the other tables using LoadDataRow since the structure will
> always
> be the same.
>
> Since the format of each table is the same I'm using
> LoadDataRow(myRowToAdd). I have tried creating a new AutoIncrementColumn
> and
> LoadingDataRow but this doesn't work, I end up with NULLS in the new
> Column
> and of course non unique values in the existing.
>
> So I guess my question is what is the best way to create this new
> autoincrement column? I'm hoping I don't have to loop through the
> datatables
> that come in because I will be recieving updates to all this data and
> think
> this could be quite slow.
>
> Any help appreciated.
>
> Thanks
Author
28 Jan 2007 12:46 PM
Neil
Hi Cor,

Thanks for the suggestion. I have used the GUID before but in this case it
won't help me. I should have mentioned why I was wanting the AutoIncrement
Column...

I have an initial dataload stage which see's my client recieve several data
tables, each of these is combined into one table and then bound to a grid. I
also will recieve updates to the initial data loads and new datarows as time
goes on. I was using the AutoIncrement column as a Row Indexer something
along the lines of code below (excuse syntax errors). This just saves me
looping through the initial data table for each update I have and hence it's
a bit quicker. Otherwise I might be looping through my initial data table
(2000 records) just to update 2 rows. Perhaps there is a better way to do
this...?

Thanks


string uniqueIdent = myUpdateRow["UniqueKey"].ToString();

DataRow foundRow = myInitialData.Find(uniqueIdent);

if(foundRow != null) //it's an update
{
  int rowIdx = (int)foundRow["myAutoIncrementCol"].ToString();

  //Loop through all columns in the row to see if any values have changed
using RowIdx
  myInitialData.Rows[rowIdx][colIdx] != updateRow[colIdx]
}
else //New Record
{
  myInitialData.LoadDataRow(updateRow);
}



Show quote
"Cor Ligthert [MVP]" wrote:

> Neil,
>
> Therefore try to forget in this century the simple autoincrement id and use
> the Global Unique Identifier (GUID) in SQL the Unique Identifier to make
> ID's. You know, you are not the first with the problems you are describing.
>
> Just my thought,
>
> Cor
>
> "Neil" <N***@discussions.microsoft.com> schreef in bericht
> news:B5DB0625-3D92-426F-9A0F-8B310F322697@microsoft.com...
> > Hi,
> >
> > I'm wondering if it's possible to regenerate the increment id's in an
> > AutoIncrement Column?
> >
> > My situation is this...I have a client application that is recieving a
> > several DataTables from a service. The DataTables contain an auto
> > increment
> > column which is guaranteed to be unique within that table but I need to
> > merge
> > the tables together to create a new table and still have a unique column.
> >
> > Orignally I was taking the first table as a base and then adding new rows
> > to
> > this for the other tables using LoadDataRow since the structure will
> > always
> > be the same.
> >
> > Since the format of each table is the same I'm using
> > LoadDataRow(myRowToAdd). I have tried creating a new AutoIncrementColumn
> > and
> > LoadingDataRow but this doesn't work, I end up with NULLS in the new
> > Column
> > and of course non unique values in the existing.
> >
> > So I guess my question is what is the best way to create this new
> > autoincrement column? I'm hoping I don't have to loop through the
> > datatables
> > that come in because I will be recieving updates to all this data and
> > think
> > this could be quite slow.
> >
> > Any help appreciated.
> >
> > Thanks
>
>
>
Author
28 Jan 2007 1:09 PM
Cor Ligthert [MVP]
Neil,

Are you sure that you cannot use the merge.

http://www.vb-tips.com/dbpages.aspx?ID=edb1409d-5394-468f-a63f-de3a5d92b14a

Cor


Show quote
"Neil" <N***@discussions.microsoft.com> schreef in bericht
news:B382BAF3-55AD-489D-8B2B-87148F26DF8E@microsoft.com...
> Hi Cor,
>
> Thanks for the suggestion. I have used the GUID before but in this case it
> won't help me. I should have mentioned why I was wanting the AutoIncrement
> Column...
>
> I have an initial dataload stage which see's my client recieve several
> data
> tables, each of these is combined into one table and then bound to a grid.
> I
> also will recieve updates to the initial data loads and new datarows as
> time
> goes on. I was using the AutoIncrement column as a Row Indexer something
> along the lines of code below (excuse syntax errors). This just saves me
> looping through the initial data table for each update I have and hence
> it's
> a bit quicker. Otherwise I might be looping through my initial data table
> (2000 records) just to update 2 rows. Perhaps there is a better way to do
> this...?
>
> Thanks
>
>
> string uniqueIdent = myUpdateRow["UniqueKey"].ToString();
>
> DataRow foundRow = myInitialData.Find(uniqueIdent);
>
> if(foundRow != null) //it's an update
> {
>  int rowIdx = (int)foundRow["myAutoIncrementCol"].ToString();
>
>  //Loop through all columns in the row to see if any values have changed
> using RowIdx
>  myInitialData.Rows[rowIdx][colIdx] != updateRow[colIdx]
> }
> else //New Record
> {
>  myInitialData.LoadDataRow(updateRow);
> }
>
>
>
> "Cor Ligthert [MVP]" wrote:
>
>> Neil,
>>
>> Therefore try to forget in this century the simple autoincrement id and
>> use
>> the Global Unique Identifier (GUID) in SQL the Unique Identifier to make
>> ID's. You know, you are not the first with the problems you are
>> describing.
>>
>> Just my thought,
>>
>> Cor
>>
>> "Neil" <N***@discussions.microsoft.com> schreef in bericht
>> news:B5DB0625-3D92-426F-9A0F-8B310F322697@microsoft.com...
>> > Hi,
>> >
>> > I'm wondering if it's possible to regenerate the increment id's in an
>> > AutoIncrement Column?
>> >
>> > My situation is this...I have a client application that is recieving a
>> > several DataTables from a service. The DataTables contain an auto
>> > increment
>> > column which is guaranteed to be unique within that table but I need to
>> > merge
>> > the tables together to create a new table and still have a unique
>> > column.
>> >
>> > Orignally I was taking the first table as a base and then adding new
>> > rows
>> > to
>> > this for the other tables using LoadDataRow since the structure will
>> > always
>> > be the same.
>> >
>> > Since the format of each table is the same I'm using
>> > LoadDataRow(myRowToAdd). I have tried creating a new
>> > AutoIncrementColumn
>> > and
>> > LoadingDataRow but this doesn't work, I end up with NULLS in the new
>> > Column
>> > and of course non unique values in the existing.
>> >
>> > So I guess my question is what is the best way to create this new
>> > autoincrement column? I'm hoping I don't have to loop through the
>> > datatables
>> > that come in because I will be recieving updates to all this data and
>> > think
>> > this could be quite slow.
>> >
>> > Any help appreciated.
>> >
>> > Thanks
>>
>>
>>
Author
29 Jan 2007 3:42 PM
AMDRIT
If the merge function does not work, you can overrload it to do what you
want it to do.  Set your step and increment to -1, this way you will not run
into duplicate numbers.


Show quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:uiJrA1tQHHA.4744@TK2MSFTNGP02.phx.gbl...
> Neil,
>
> Are you sure that you cannot use the merge.
>
> http://www.vb-tips.com/dbpages.aspx?ID=edb1409d-5394-468f-a63f-de3a5d92b14a
>
> Cor
>
>
> "Neil" <N***@discussions.microsoft.com> schreef in bericht
> news:B382BAF3-55AD-489D-8B2B-87148F26DF8E@microsoft.com...
>> Hi Cor,
>>
>> Thanks for the suggestion. I have used the GUID before but in this case
>> it
>> won't help me. I should have mentioned why I was wanting the
>> AutoIncrement
>> Column...
>>
>> I have an initial dataload stage which see's my client recieve several
>> data
>> tables, each of these is combined into one table and then bound to a
>> grid. I
>> also will recieve updates to the initial data loads and new datarows as
>> time
>> goes on. I was using the AutoIncrement column as a Row Indexer something
>> along the lines of code below (excuse syntax errors). This just saves me
>> looping through the initial data table for each update I have and hence
>> it's
>> a bit quicker. Otherwise I might be looping through my initial data table
>> (2000 records) just to update 2 rows. Perhaps there is a better way to do
>> this...?
>>
>> Thanks
>>
>>
>> string uniqueIdent = myUpdateRow["UniqueKey"].ToString();
>>
>> DataRow foundRow = myInitialData.Find(uniqueIdent);
>>
>> if(foundRow != null) //it's an update
>> {
>>  int rowIdx = (int)foundRow["myAutoIncrementCol"].ToString();
>>
>>  //Loop through all columns in the row to see if any values have changed
>> using RowIdx
>>  myInitialData.Rows[rowIdx][colIdx] != updateRow[colIdx]
>> }
>> else //New Record
>> {
>>  myInitialData.LoadDataRow(updateRow);
>> }
>>
>>
>>
>> "Cor Ligthert [MVP]" wrote:
>>
>>> Neil,
>>>
>>> Therefore try to forget in this century the simple autoincrement id and
>>> use
>>> the Global Unique Identifier (GUID) in SQL the Unique Identifier to make
>>> ID's. You know, you are not the first with the problems you are
>>> describing.
>>>
>>> Just my thought,
>>>
>>> Cor
>>>
>>> "Neil" <N***@discussions.microsoft.com> schreef in bericht
>>> news:B5DB0625-3D92-426F-9A0F-8B310F322697@microsoft.com...
>>> > Hi,
>>> >
>>> > I'm wondering if it's possible to regenerate the increment id's in an
>>> > AutoIncrement Column?
>>> >
>>> > My situation is this...I have a client application that is recieving a
>>> > several DataTables from a service. The DataTables contain an auto
>>> > increment
>>> > column which is guaranteed to be unique within that table but I need
>>> > to
>>> > merge
>>> > the tables together to create a new table and still have a unique
>>> > column.
>>> >
>>> > Orignally I was taking the first table as a base and then adding new
>>> > rows
>>> > to
>>> > this for the other tables using LoadDataRow since the structure will
>>> > always
>>> > be the same.
>>> >
>>> > Since the format of each table is the same I'm using
>>> > LoadDataRow(myRowToAdd). I have tried creating a new
>>> > AutoIncrementColumn
>>> > and
>>> > LoadingDataRow but this doesn't work, I end up with NULLS in the new
>>> > Column
>>> > and of course non unique values in the existing.
>>> >
>>> > So I guess my question is what is the best way to create this new
>>> > autoincrement column? I'm hoping I don't have to loop through the
>>> > datatables
>>> > that come in because I will be recieving updates to all this data and
>>> > think
>>> > this could be quite slow.
>>> >
>>> > Any help appreciated.
>>> >
>>> > Thanks
>>>
>>>
>>>
>
>

AddThis Social Bookmark Button