Typed Dataset for insert and Updates for Identity field

  • Thread starter Thread starter lloyd M
  • Start date Start date
L

lloyd M

Hi,

I have a User table as follows
=================================================
Name Type
=================================================
UID Int AutoIncrement
USER_NAME Varchar
USER_PASSWORD Varchar

Now I have a Typed Dataset as follows

With table.Columns
With table.Columns.Add(PK_ID, GetType(System.Int32))
.AllowDBNull = False
.AutoIncrement = True
End With
.Add("USER_NAME", GetType(System.String)).AllowDBNull = False
.Add("USER_PASSWORD", GetType(System.String)).AllowDBNull = False
End With

when i perform an update rquest everything is alright since i will be
supplying the UID.
When i perform an INSERT it will not allow me because of Primary Key
Constraint and that is fine. SO my question is how to use the same
typed dataset but bypass the UID typed key. Is there any way to pass a
blank into this position.
Ideally i need to build another dataset just accepting User_Name and
User_Password for Inserts and UID,User_Name and User_Password for
Updates; but this is not a practicle approach

So how do i use the same Typed Dataset for both Inserts and Updates???
I hope my question is clear and if someone can help me out???
 
Check out Bill Vaughn's Artice on Managing An Identity Crisis at
www.betav.com Article -> MSDN.
Basiclly, you need to set the autoincrmement value to -1 so you always have
an internal value that will never exist in the db so when you submit insert,
the DB will assign the values.
 
Back
Top