[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

FillSchema not bringing in UniqueConstraint column information

I have to to an upsert into a table with known format, but unkown constraints.   The user database can be configured as they like, and I have to get my upsert command to handle this.

If my insert fails I go to my update command, but I can't seem to figure out how to get the unique constraints into the dataset from the table!

da is a sqlDataAdapter
ds is the dataset.

         da.MissingSchemaAction = MissingSchemaAction.AddWithKey
         da.FillSchema(ds, SchemaType.Source, tableName)

If there is a primary key I can get this information out of the local database, but I can't figure out a way to find the # of columns that make up the unique constraint on this table...

how can I get a list of those columns?

I've also tried dc.unique for each of the columns but it always returns false.  

I'm expecting 4 or 5 columns in each table to make up the unique constraint.   Help!

1 Solution
bswiftlyAuthor Commented:
figured it out.

you have to declare a unique constraint and pull it out of the constraint collection.

dim unique as UniqueConstraint

unique = ds.tables(0).constraints(0)

then you have access to what you need from the unique variable..

points refunded!
Question closed and 50 points refunded

CS Moderator

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now