PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET can not access foreign key constraint

Reply

can not access foreign key constraint

 
Thread Tools Rate Thread
Old 30-06-2003, 12:33 PM   #1
Rajesh Tiwari
Guest
 
Posts: n/a
Default 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



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off