954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Finding Primary Key in MySQL Database

Hey all,

Apologies for this question, as I imagine it will be very easy.

I'm creating a form that will be used to update fields in a table. I don't want the user to be able to update primary keys though, so I'm trying to disable the textbox so it can't be edited.

The textboxes are created during runtime, so I'm trying to create an If loop that will see if it is on the primary key column, but i'm unsure of how to do this. I tried doing this:

If dt.Columns(i).Unique = True Then
t(i).Enabled = False
End If


But this didn't work. I found an option called PrimaryKey which would go dt.PrimaryKey... something (I'm guessing) but just unsure of how to use it.

Thanks in advance :)

Wolxhound90
Junior Poster in Training
55 posts since Mar 2011
Reputation Points: 10
Solved Threads: 1
 

If the Primary key is of datatype integer and auto-incrementing, then just delete that field from your "insert" and "Update Set" command. Mysql will take care of it.

GeekByChoiCe
Master Poster
721 posts since Jun 2009
Reputation Points: 208
Solved Threads: 168
 

Sorry for delayed reply.

Yeah, I may have to do this. Can't seem to find any other way around it lol. Thanks for your answer :)

Wolxhound90
Junior Poster in Training
55 posts since Mar 2011
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: