Displaying the constraints

  • Thread starter Thread starter raj
  • Start date Start date
R

raj

How do I display the constraints that the Oracle database
table has?(btw I'm working on .net)
 
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
 
Back
Top