Ben,

Thanks for the feedback. I am using dataAdapter to fill my DataSet. I
am then allowing user to make multiple manipulations to the DataSet.
The user can update, insert, and delete DataTable rows. And then when
the user is finished making edits, I have my routine that I have
written that updates my SQL Database. I am not using the primary keys
for rows that I am inserting into my database, so there will be no
concurrency or duplication issues. I just need the ability to create a
unique ID when inserting a new DataTable row so that it won't error
out and allows me to insert the row. I will not be using this unique
ID for anything else.

Trevor

--- In [EMAIL PROTECTED], "Ben Miller"
<[EMAIL PROTECTED]> wrote:
> The major thing with this is that you can create a unique id for the
primary key in the DataTable, but what is your intention of the
DataTable?  Are you looking to use this in a DataAdapter and do a
.Update, and have the adapter insert the record?  If so then you don't
have a very good mechanism to do that.
> 
> What I hear is that you have a table that the key for the record
would be the Max(recordid) for the primary key.  But you put the
record in memory in the DataTable, meanwhile someone using the site
inserts a record and uses this id, and now when you go to update it,
then you will have a problem with duplicate Primary Key values (which
cannot exist).
> 
> So you have to decide what and where you are going to use this data,
because you will have concurrency problems the way you are telling us
that you have it designed.
> 
> The table looks good, except we do not know what you intend on doing
with your DataTable you are creating the new row in (because the
DataTable is not connected to the SQL Server or database server).  
> 
> I hope this makes sense?
> 
> Ben Miller.
>   ----- Original Message ----- 
>   From: Trevor Thompson 
>   To: [EMAIL PROTECTED] 
>   Sent: Monday, August 16, 2004 3:11 PM
>   Subject: [AspNetAnyQuestionIsOk] Re: finding largest primary key
value in my DataSet
> 
> 
>   To be clear, I want to add a new row to my DataTable, not to my 
>   actual database. The problem i am running into is that when I attempt 
>   to do the following..
> 
>   DataRow dr= ds.Tables[0].NewRow();
>   dr["pay_adjust_id"] = //needs unique value here for primary key
>   dr["pay_adjust_vers_id"] = add_pay_adjust_vers_id;
>   dr["ctype_grp_cd"] = add_ctype_grp_cd;
>   dr["pay_adjust_type_cd"] = "P";
>   dr["proj_fy"] = add_proj_fy;
>   dr["proj_fm"] = add_proj_fm;
>   dr["prcnt"] = addPCNT;
>   dr["narrative"] = addNAR;
> 
>   ds.Tables[0].Rows.Add(dr); 
> 
>   it needs a unique value for the primary key. Does anyone know how I 
>   can come up with a unique value for my primary key column? Thanks!
> 
> 
> 
> 
>   --- In [EMAIL PROTECTED], shannon hall 
>   <[EMAIL PROTECTED]> wrote:
>   > If you aren't going to use the object for what it was
>   > designed for then I would suggest not using it at all.
>   >  Use a command object and fire off an insert statement
>   > and refill whatever "reader" type of object you
>   > implemented.
>   > 
>   > 
>   > 
>   > --- Trevor Thompson <[EMAIL PROTECTED]> wrote:
>   > 
>   > > well that's neither here nor there. there are many
>   > > reasons why i 
>   > > chose to take the route i have taken. my main
>   > > concern is how to add a 
>   > > unique id for the value of my column that i have
>   > > designated as my 
>   > > primary key in my dataset when i insert a new row.
>   > > any help with this 
>   > > would be greatly appreciated. thanks!
>   > > 
>   > > --- In [EMAIL PROTECTED],
>   > > shannon hall 
>   > > <[EMAIL PROTECTED]> wrote:
>   > > > If you are already using a dataadapter then why
>   > > not 
>   > > > use the functionality it provides?  Otherwise slam
>   > > > your data into a data table and fire off an insert
>   > > > stored procedure on the server and refresh the
>   > > data
>   > > > table after complete.
>   > > > 
>   > > > If this is a web application I would suggest using
>   > > > sp's and data reader's.
>   > > > 
>   > > > 
>   > > > 
>   > > > --- Trevor Thompson <[EMAIL PROTECTED]> wrote:
>   > > > 
>   > > > > i'm not using the dataAdapter to insert, update,
>   > > or
>   > > > > delete. i'm just 
>   > > > > using it to select and fill. and then i'm taking
>   > > > > care of the rest 
>   > > > > myself.
>   > > > > 
>   > > > > --- In [EMAIL PROTECTED],
>   > > > > shannon hall 
>   > > > > <[EMAIL PROTECTED]> wrote:
>   > > > > > Not only will the table have to have a
>   > > Identity
>   > > > > insert
>   > > > > > but you should havea  data table derived from
>   > > a
>   > > > > data
>   > > > > > adapter with the appropriate select, insert,
>   > > > > update
>   > > > > > and delete statements.  This way, your data
>   > > > > integrity
>   > > > > > is insurred.
>   > > > > > 
>   > > > > > 
>   > > > > > --- Onur Bozkurt <[EMAIL PROTECTED]> wrote:
>   > > > > > 
>   > > > > > > why don't use use "Identity Insert" ? Create
>   > > a
>   > > > > > > column and make its Identity property to
>   > > true.
>   > > > > > >   ----- Original Message ----- 
>   > > > > > >   From: Trevor Thompson 
>   > > > > > >   To: [EMAIL PROTECTED] 
>   > > > > > >   Sent: Monday, August 16, 2004 9:42 PM
>   > > > > > >   Subject: [AspNetAnyQuestionIsOk] finding
>   > > > > largest
>   > > > > > > primary key value in my DataSet
>   > > > > > > 
>   > > > > > > 
>   > > > > > >   i need to insert a new row in my dataset
>   > > > > > > datatable. my datatable has 
>   > > > > > >   a primary key. i need to assign a unique
>   > > value
>   > > > > for
>   > > > > > > my primary key 
>   > > > > > >   column in my newly inserted row. how can i
>   > > do
>   > > > > > > this? i need to figure 
>   > > > > > >   out how to find the max value of primary
>   > > key
>   > > > > in my
>   > > > > > > dataset and add a 
>   > > > > > >   1 to it to have an unused unique value.
>   > > > > > > 
>   > > > > > >   tks! 
>   > > > > > > 
>   > > > > > > 
>   > > > > > >         Yahoo! Groups Sponsor 
>   > > > > > >               ADVERTISEMENT
>   > > > > > >              
>   > > > > > >        
>   > > > > > >        
>   > > > > > > 
>   > > > > > > 
>   > > > > > >
>   > > > > >
>   > > > >
>   > > >
>   > >
>   > --------------------------------------------------------------------
>   > > > > ----------
>   > > > > > >   Yahoo! Groups Links
>   > > > > > > 
>   > > > > > >     a.. To visit your group on the web, go
>   > > to:
>   > > > > > >    
>   > > > > > >
>   > > > >
>   > > http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
>   > > > > > >       
>   > > > > > >     b.. To unsubscribe from this group, send
>   > > an
>   > > > > > > email to:
>   > > > > > >    
>   > > > > > >
>   > > > >
>   > > [EMAIL PROTECTED]
>   > > > > > >       
>   > > > > > >     c.. Your use of Yahoo! Groups is subject
>   > > to
>   > > > > the
>   > > > > > > Yahoo! Terms of Service. 
>   > > > > > > 
>   > > > > > > 
>   > > > > > > 
>   > > > > > > [Non-text portions of this message have been
>   > > > > > > removed]
>   > > > > > > 
>   > > > > > > 
>   > > > > > 
>   > > > > > 
>   > > > > > 
>   > > > > >             
>   > > > > > _______________________________
>   > > > > > Do you Yahoo!?
>   > > > > > Express yourself with Y! Messenger! Free.
>   > > Download
>   > > > > now. 
>   > > > > > http://messenger.yahoo.com
>   > > > > 
>   > > > > 
>   > > > 
>   > > > 
>   > > > 
>   > > >             
>   > > > __________________________________
>   > > > Do you Yahoo!?
>   > > > Yahoo! Mail - 50x more storage than other
>   > > providers!
>   > > > http://promotions.yahoo.com/new_mail
>   > > 
>   > > 
>   > 
>   > 
>   > 
>   >             
>   > __________________________________
>   > Do you Yahoo!?
>   > Yahoo! Mail is new and improved - Check it out!
>   > http://promotions.yahoo.com/new_mail
> 
> 
>         Yahoo! Groups Sponsor 
>               ADVERTISEMENT
>              
>        
>        
> 
> 
>
------------------------------------------------------------------------------
>   Yahoo! Groups Links
> 
>     a.. To visit your group on the web, go to:
>     http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
>       
>     b.. To unsubscribe from this group, send an email to:
>     [EMAIL PROTECTED]
>       
>     c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service. 
> 
> 
> 
> [Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to