The GetSchema documentation hurts, specifically:
"Understanding the Provider-Specific Schema Collections" at
http://msdn2.microsoft.com/en-us/library/ms254969(VS.80).aspx

I'm trying to create a DataSet that matches an SQL Server database, and I've
gotten close.

I'm calling SqlConnection's GetSchema( "Tables"), and then for each table
name, I'm doing:

sqlDataAdapter = new SqlDataAdapter( "SELECT * FROM " + dataTableName,
sqlConnection);
sqlDataAdapter.FillSchema( dataSet, SchemaType.Mapped, dataTableName);

Doing so initializes the data tables of the data set, including primary
keys. What remains to be done is to create the foreign key constraints.

Calling GetSchema( "ForeignKeys") returns the following columns:
CONSTRAINT_CATALOG
CONSTRAINT_SCHEMA
CONSTRAINT_NAME
TABLE_CATALOG
TABLE_SCHEMA
TABLE_NAME
CONSTRAINT_TYPE
IS_DEFERRABLE
INITIALLY_DEFERRED

What I expected to see was a local table name, the local field of the
foreign key, the referenced table name, and the primary key field of the
referenced table. Where is that?

Thanks in advance.

RE: How does GetSchema get foreign key constraints? by ManishBafna

ManishBafna
Wed May 16 03:39:01 CDT 2007

Hi,
In below Link one MSFT has already answered this query:
http://msdn.microsoft.com/newsgroups/default.aspx?pg=3&lang=en&cr=US&guid=&sloc=en-us&dg=microsoft.public.dotnet.framework.adonet&fltr=

Look for Get PK:FK post in above page
Hope this helps
--
Thanks and Regards.
Manish Bafna.
MCP and MCTS.



"uncaged" wrote:

> The GetSchema documentation hurts, specifically:
> "Understanding the Provider-Specific Schema Collections" at
> http://msdn2.microsoft.com/en-us/library/ms254969(VS.80).aspx
>
> I'm trying to create a DataSet that matches an SQL Server database, and I've
> gotten close.
>
> I'm calling SqlConnection's GetSchema( "Tables"), and then for each table
> name, I'm doing:
>
> sqlDataAdapter = new SqlDataAdapter( "SELECT * FROM " + dataTableName,
> sqlConnection);
> sqlDataAdapter.FillSchema( dataSet, SchemaType.Mapped, dataTableName);
>
> Doing so initializes the data tables of the data set, including primary
> keys. What remains to be done is to create the foreign key constraints.
>
> Calling GetSchema( "ForeignKeys") returns the following columns:
> CONSTRAINT_CATALOG
> CONSTRAINT_SCHEMA
> CONSTRAINT_NAME
> TABLE_CATALOG
> TABLE_SCHEMA
> TABLE_NAME
> CONSTRAINT_TYPE
> IS_DEFERRABLE
> INITIALLY_DEFERRED
>
> What I expected to see was a local table name, the local field of the
> foreign key, the referenced table name, and the primary key field of the
> referenced table. Where is that?
>
> Thanks in advance.
>

RE: How does GetSchema get foreign key constraints? by uncaged

uncaged
Wed May 16 08:45:00 CDT 2007

Thanks.

How lame of Microsoft not to have GetSchema() return foreign keys,
especially since it returns a collection called "ForeignKeys". What value is
that collection supposed to serve, if it doesn't show the table and PK to
which it's linked?


"Manish Bafna" wrote:

> Hi,
> In below Link one MSFT has already answered this query:
> http://msdn.microsoft.com/newsgroups/default.aspx?pg=3&lang=en&cr=US&guid=&sloc=en-us&dg=microsoft.public.dotnet.framework.adonet&fltr=
>
> Look for Get PK:FK post in above page
> Hope this helps
> --
> Thanks and Regards.
> Manish Bafna.
> MCP and MCTS.
>
>
>
> "uncaged" wrote:
>
> > The GetSchema documentation hurts, specifically:
> > "Understanding the Provider-Specific Schema Collections" at
> > http://msdn2.microsoft.com/en-us/library/ms254969(VS.80).aspx
> >
> > I'm trying to create a DataSet that matches an SQL Server database, and I've
> > gotten close.
> >
> > I'm calling SqlConnection's GetSchema( "Tables"), and then for each table
> > name, I'm doing:
> >
> > sqlDataAdapter = new SqlDataAdapter( "SELECT * FROM " + dataTableName,
> > sqlConnection);
> > sqlDataAdapter.FillSchema( dataSet, SchemaType.Mapped, dataTableName);
> >
> > Doing so initializes the data tables of the data set, including primary
> > keys. What remains to be done is to create the foreign key constraints.
> >
> > Calling GetSchema( "ForeignKeys") returns the following columns:
> > CONSTRAINT_CATALOG
> > CONSTRAINT_SCHEMA
> > CONSTRAINT_NAME
> > TABLE_CATALOG
> > TABLE_SCHEMA
> > TABLE_NAME
> > CONSTRAINT_TYPE
> > IS_DEFERRABLE
> > INITIALLY_DEFERRED
> >
> > What I expected to see was a local table name, the local field of the
> > foreign key, the referenced table name, and the primary key field of the
> > referenced table. Where is that?
> >
> > Thanks in advance.
> >

RE: How does GetSchema get foreign key constraints? by thielen

thielen
Wed May 23 00:08:02 CDT 2007

Take a look at Kailua at http://www.windwardreports.com/open_source.htm - it
provides this for SqlServer with DB2, MySql, and Oracle coming.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm



RE: How does GetSchema get foreign key constraints? by DRB

DRB
Thu Nov 01 13:07:03 PDT 2007

Where is this link now?

"Manish Bafna" wrote:

> Hi,
> In below Link one MSFT has already answered this query:
> http://msdn.microsoft.com/newsgroups/default.aspx?pg=3&lang=en&cr=US&guid=&sloc=en-us&dg=microsoft.public.dotnet.framework.adonet&fltr=
>
> Look for Get PK:FK post in above page
> Hope this helps
> --
> Thanks and Regards.
> Manish Bafna.
> MCP and MCTS.
>
>
>
> "uncaged" wrote:
>
> > The GetSchema documentation hurts, specifically:
> > "Understanding the Provider-Specific Schema Collections" at
> > http://msdn2.microsoft.com/en-us/library/ms254969(VS.80).aspx
> >
> > I'm trying to create a DataSet that matches an SQL Server database, and I've
> > gotten close.
> >
> > I'm calling SqlConnection's GetSchema( "Tables"), and then for each table
> > name, I'm doing:
> >
> > sqlDataAdapter = new SqlDataAdapter( "SELECT * FROM " + dataTableName,
> > sqlConnection);
> > sqlDataAdapter.FillSchema( dataSet, SchemaType.Mapped, dataTableName);
> >
> > Doing so initializes the data tables of the data set, including primary
> > keys. What remains to be done is to create the foreign key constraints.
> >
> > Calling GetSchema( "ForeignKeys") returns the following columns:
> > CONSTRAINT_CATALOG
> > CONSTRAINT_SCHEMA
> > CONSTRAINT_NAME
> > TABLE_CATALOG
> > TABLE_SCHEMA
> > TABLE_NAME
> > CONSTRAINT_TYPE
> > IS_DEFERRABLE
> > INITIALLY_DEFERRED
> >
> > What I expected to see was a local table name, the local field of the
> > foreign key, the referenced table name, and the primary key field of the
> > referenced table. Where is that?
> >
> > Thanks in advance.
> >