FillSchema not bringing in UniqueConstraint column information

Posted on 2005-05-16
Last Modified: 2008-01-09
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!

Question by:bswiftly
    LVL 1

    Author Comment

    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!

    Accepted Solution

    Question closed and 50 points refunded

    CS Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now