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 :)

Recommended Answers

All 2 Replies

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.

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 :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.