473,395 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Can Not Access Foreign Key Constraint

Hi Group,
i have a foreign key in a table in sql server.i am using a dataset and
populating it with the contents of this table.my problem is that i am not
able to access the foreign key that i cretaed on this table in the
database.i am using a code something like this.if i check the number of
constraints on the table it prints 1,which is nothing but the primary key
constraint on this table,why doesn't it print 2 and show both primary and
foreign key constraint.i have tried most of the combinations in the code
below.
plz help.

DataSet myDataSet = new DataSet("myDataSet");
myDataSet.EnforceConstraints=true;
SqlDataAdapter adpt=new SqlDataAdapter("select * from "+TableName,con);
//adpt.MissingSchemaAction = MissingSchemaAction.AddWithKey;
adpt.FillSchema(myDataSet,SchemaType.Mapped);
Response.Write(myDataSet.Relations.Count);
Response.Write(myDataSet.Tables["Table"].Constraints.Count);
//Response.Write(myDataSet.Tables["dtbl"].Constraints[0].ConstraintName);
//Response.Write(myDataSet.Tables["dtbl"].Constraints[0].GetType());

thanks in advance

--
Rajesh Tiwari


Nov 17 '05 #1
0 1890

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Luc Martineau | last post by:
Hello When we create a table, what is the difference between the REFERENCE constraint on column and the FOREIGN KEY constraint on table ? I guess that the FOREIGN KEY constraint assures us...
0
by: Jeremiah Jacks | last post by:
I just upgraded to MySQL 4.0.14-standard for RedHat Linux and am using = the pre-compiled binaries. I have a database with INNODB tables. When I insert a row into one of the child tables, I get...
2
by: Gunnar Vøyenli | last post by:
Hi! For the sake of simplicity, I have three tables, Employee, Department and Work Employee >---- Department \ / \ / ^ ^ Work
31
by: Robert Brown | last post by:
Let's say I have a type hierarchy: (just an example) the general entity customer: CREATE TABLE customer(customer_id int, customer_name varchar(250), customer_type int) three specific...
2
by: adammitchell | last post by:
How can you indicate that a FOREIGN KEY constraint references two columns in two different tables? "SQL Server Books Online" show an example of how to reference two columns in the SAME table:...
13
by: Bob Stearns | last post by:
Why is the following constraint invalid? I want to make sure that every row in IS3.ANIMALS_PRIV_INDEXES matches one of those in IS3.table_var_defn with part of the primary key fixed. Since this is...
2
by: Alfredo | last post by:
Hello, I have created the following table and her relations CREATE TABLE bannerdetail (objectname VARCHAR(30), elementname VARCHAR(30), sequence SMALLINT) ; CREATE UNIQUE INDEX primarykey ON...
13
by: Tibor | last post by:
I am using PostgreSQL 7.4.1 (only through psql) I know, that the command ALTER TABLE OFFICES DROP PRIMARY KEY (CITY); and its foreign key equivalent: ALTER TABLE SALESREPS DROP CONSTRAINT
0
by: freeskier | last post by:
Hello, Sorry for the newb question; I've spent a good amount of time trying to figure this out. I am fairly new to the Postgre world. I am currently in the process of upsizing several MS Access...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.