473,789 Members | 2,516 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("myData Set");
myDataSet.Enfor ceConstraints=t rue;
SqlDataAdapter adpt=new SqlDataAdapter( "select * from "+TableName,con );
//adpt.MissingSch emaAction = MissingSchemaAc tion.AddWithKey ;
adpt.FillSchema (myDataSet,Sche maType.Mapped);
Response.Write( myDataSet.Relat ions.Count);
Response.Write( myDataSet.Table s["Table"].Constraints.Co unt);
//Response.Write( myDataSet.Table s["dtbl"].Constraints[0].ConstraintName );
//Response.Write( myDataSet.Table s["dtbl"].Constraints[0].GetType());

thanks in advance

--
Rajesh Tiwari


Nov 17 '05 #1
0 1908

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

Similar topics

0
6406
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 that the referenced column is a PRIMARY KEY in an another table. You can reference any colums with the REFERENCE constraint on column. Am I right?
0
2635
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 the following = MySQL error: INSERT INTO product_access_level (product_id,access_level_id) VALUES
2
39428
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
3384
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 customer subtypes: 1 - business, 2 - home, 3 - university
2
27001
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: REFERENCES ref_table ) Here is the error and the 'bad' SQL code: Server: Msg 8148, Level 16, State 1, Line 4
13
3702
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 illegal with the following message, how do I achieve this result? The last thing below is a working constraint from another table. ALTER TABLE IS3.ANIMALS_PRIV_INDEXES ADD CONSTRAINT FOREIGN KEY(3, variable_id) REFERENCES...
2
4160
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 bannerdetail (objectname, elementname, sequence) ; CREATE INDEX bannerheaderbannerdetail ON bannerdetail (objectname) ; CREATE INDEX elementsstorebannerdetail ON bannerdetail (elementname) ;
13
51646
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
2646
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 apps to a single PostgreSQL system; I will continue to use Access as the frontend. I have duplicated the table structure in Postgre and have successfully connected Access as a frontend to view data. I am having trouble inserting a record into...
0
10404
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10195
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9979
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6765
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4090
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2906
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.