Displaying the constraints

R

raj

How do I display the constraints that the Oracle database
table has?(btw I'm working on .net)
 
S

srinivas moorthy

Basically need to go for
System.Data.OleDb Namespace as your back end is Oracle.
Secondly the list of constraints to be displayed as just
follow the code snippet down below.
--------------------------------------------------------

oCmd.CommandText = <spname>
oCmd.CommandType = CommandType.StoredProcedure
oCmd.Connection = <conn object>
Dim sqlAdapter As New SqlDataAdapter(oCmd)
Dim Ds as New DataSet()

Try
Ds.EnforceConstraints = True
sqlAdapter.FillSchema(Ds, SchemaType.Mapped)
Dim cons As Constraint
For Each Dt In Ds.Tables
MessageBox.Show(Dt.TableName)
MessageBox.Show(Dt.Constraints.Count)
colArr = Dt.PrimaryKey

'For Each element In colArr
'MessageBox.Show("PrimaryKey : " + element)
'Next
For Each cons In Dt.Constraints
MessageBox.Show
(cons.ConstraintName.ToString())
MessageBox.Show(cons.GetType.ToString
())
Next

Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top