Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / June 2007

Tip: Looking for answers? Try searching our database.

DataTable.PrimaryKey Can I change the values of a primary key?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
NordeDakota - 22 Jun 2007 18:45 GMT
Scenario: using .NET DataTable and reading an existing record from MS
SQL Database using Ado.Net, and having .Net and SQL define the primary
key using FillSchema.

When I alter or change the values and I update or AcceptChanges my
record is modified as expected in the database. What I'm wondering and
I have not tested, yet, if I load an existing record from the data
source into a DataTable and the PrimaryKey is defaulted... should .Net
stop me or throw an exception if I try to alter a primary key value?

If I load a customer record into my DataTable with CustomerID as the
PrimaryKey and from the load this value is 1234; I think that the
DataTable should throw an exception if I attempt to change 1234 to
9987 or something else. However, I suspsect that .Net will allow me to
change a primary key value.
David Ching - 23 Jun 2007 06:59 GMT
> Scenario: using .NET DataTable and reading an existing record from MS
> SQL Database using Ado.Net, and having .Net and SQL define the primary
[quoted text clipped - 11 lines]
> 9987 or something else. However, I suspsect that .Net will allow me to
> change a primary key value.

I might very well be wrong, but my understanding of a Primary Key is that
all rows in the table have a UNIQUE value for it.  It doesn't mean you can't
change it.  If you try to change it to a value already present in another
row, perhaps that is disallowed.  I guess it's easy enough to try, though.
Let us know what happens!

-- David

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.