I wanted to post this here for two reasons: 1) in case someone might find it useful, and 2) to see if I am missing something, or, worse, doing extra work I don't have to be doing.
So recently I defined a varchar field as PK for a table and spent a little while staring at the 'cannot convert System.DBNull to the Text property of...' error trying to figure out what to do. This is what I came up with.
Note that the last three bullet points are the only additional work on top of what you would normally do. It's just very confusing at first knowing what to change and where.
{
}
As I mentioned on your other post, if you are going to be using VarChar primary keys I would create a subclassed BusinessLayer that already has the PrimaryKeyIsAutoincremented properyt set to false. All you need to do is create a class that looks something like this:
Once you have a custom business layer class created, you would then change any new business objects inherited class:
public
This way you do not have to recreate that code you had posted every time and it will respect the PrimaryKeyIsAutoIncremented property through the inherited class.
In the BO designer, set the PrimaryKeyIsAutoIncremented property to False.
Much easier! Thanks, Trent!