HOW TO: Avoide “Cannot create a child list for field …..”

From: Burton G. Wilkins (BurtonGWilkins_at_discussions.microsoft.com)
Date: 07/23/04


Date: Fri, 23 Jul 2004 07:57:07 -0700

Dear ADO.Net community:

I entered this question last night but now I can't find it this morning. I hope I am not creating double entried.

As an object, I am trying to develop some ADO.Net code which would process a relational SLQ query on a variety of SQL platforms. The code I have succeeds with Microsoft SQL and Microsoft Access, but then fails for Oracle and IBM DB2. My question is, what I am I missing that would ensure performance for all platforms. The error I am getting from Oracle and DB2 are the same “Cannot create a child list for field …..” , so I suspect if I can solve one, then both will work. Please advise what’s missing.
 
For example, the following two approaches fail in Oracle when I try and run it through ADO.Net:
 
SELECT
        A.EMPNO,
        A.ENAME,
        B.DNAME
FROM
        (SCOTT.EMP A
        INNER JOIN SCOTT.DEPT B ON
        B.DEPTNO = A.DEPTNO)
 
.. or
 
SELECT
        A.EMPNO,
        A.ENAME,
        B.DNAME
FROM
        (SCOTT.EMP A
        INNER JOIN SCOTT.DEPT B ON
        B.DEPTNO = A.DEPTNO)
 
Here in general is how I am trying to return the result.
 
(1) Creates a Connection:
 
Dim mconConnection As OracleClient.OracleConnection
Dim mstrConnecion = “Data Source=WORD;User ID=SCOTT;Password=TIGER;”
 
   mconConnection = New OracleClient.OracleConnection()
  mconConnection.ConnectionString = mstrConnection
 
(2) Create a Data Adapter:
 
Dim mdaDataAdapter As OracleClient.OracleDataAdapter
Dim mstrSelect As String
 
   mstrSelect = “strSelect = "SELECT A.EMPNO, A.ENAME, B.DNAME FROM (SCOTT.EMP A INNER JOIN SCOTT.DEPT B ON B.DEPTNO = A.DEPTNO)
   mdaDataAdapter = New OracleClient.OracleDataAdapter()
   mdaDataAdapter.SelectCommand = New
   OracleClient.OracleCommand(mstrSelect, mconConnection)
 
(3) Create a Data Table:
 
   mdtDataTable = New DataTable("(SCOTT.EMP")
 
   mdcA_EMPNO = New DataColumn()
   mdcA_EMPNO.ColumnName = "A.EMPNO"
   mdcA_EMPNO.DataType = System.Type.GetType("System.Decimal")
   mdcA_EMPNO.AutoIncrement = False
   mdcA_EMPNO.Caption = "A.EMPNO”
   mdcA_EMPNO.ReadOnly = False
   mdcA_EMPNO.Unique = False
   mdtDataTable.Columns.Add(mdcA_EMPNO)
 
   mdcA_ENAME = New DataColumn()
   mdcA_ENAME.ColumnName = "A.ENAME"
   mdcA_ENAME.DataType = System.Type.GetType("System.String")
   mdcA_ENAME.AutoIncrement = False
   mdcA_ENAME.Caption = "A.ENAME"
   mdcA_ENAME.ReadOnly = False
   mdcA_ENAME.Unique = False
   mdcA_ENAME.MaxLength = 10
   mdtDataTable.Columns.Add(mdcA_ENAME)
 
   mdcB_DNAME = New DataColumn()
   mdcB_DNAME.ColumnName = "B.DNAME"
   mdcB_DNAME.DataType = System.Type.GetType("System.String")
   mdcB_DNAME.AutoIncrement = False
   mdcB_DNAME.Caption = "B.DNAME"
   mdcB_DNAME.ReadOnly = False
   mdcB_DNAME.Unique = False
   mdcB_DNAME.MaxLength = 9
   mdtDataTable.Columns.Add(mdcB_DNAME)
 
(4) Establish Table Mapping and Set Command String:
  
   Dim mTableMap As DataTableMapping
 
   mTableMap = mdaDataAdapter.TableMappings.Add("Table", "(SCOTT.EMP")
   mTableMap.ColumnMappings.Add("A.EMPNO", "A.EMPNO")
   mTableMap.ColumnMappings.Add("A.ENAME", "A.ENAME")
   mTableMap.ColumnMappings.Add("B.DNAME", "B.DNAME")
   mdaDataAdapter.SelectCommand.Connection.ConnectionString= mstrConnection
 
(5) Define Command Object
 
   Dim cmdCommand As New OracleClient.OracleCommand()
 
   cmdCommand.Connection = mconConnection
   mconConnection.Open() 'Open the connection.
   cmdCommand.CommandType = CommandType.Text
   cmdCommand.CommandText = mstrSelect
 
(6) Create and fill the Data Adapter:
 
    Dim mdaDataAdapter As OracleClient.OracleDataAdapter
    Dim mdsDataSet As DataSet
 
   mdsDataSet = New DataSet()
   mdaDataAdapter.SelectCommand = cmdCommand
   mdaDataAdapter.Fill(mdsDataSet, "(SCOTT.EMP")
 
(7) Get Record Count: (This is where the failure occurs.)
 
   mintRecordCount = Form.BindingContext(mdsDataSet, "(SCOTT.EMP").Count
 
When this last instruction is exercised, both Oracle and DB2 exception out returning the “Cannot create a child list for field SCOTT” message. Microsoft Access and SQL do not error out.
 
 So my question to all is this. What should I add to these approaches so that the ADO.Net code will not to exception out? Please offer a few lines of code.
 
I would very much appreciate your comments to this question. Thank you for reading this explanation and considering this request.
 
Sincerely,
 
Burton G. Wilkins.



Relevant Pages

  • HOW TO Avoid: "Cannot create a child list for field …." for SQL Re
    ... Dim mconConnection As OracleClient.OracleConnection ... Dim mdaDataAdapter As OracleClient.OracleDataAdapter ... mdcA_EMPNO = New DataColumn() ... When this last instruction is exercised, both Oracle and DB2 exception out returning the “Cannot create a child list for field SCOTT” message. ...
    (microsoft.public.data.ado)
  • Re: Help - Procedure expects parameter - Its There!!!
    ... Public Sub New ... Private Sub btnLoad_Click(ByVal sender As System.Object, ... Dim JobNumber As DataColumn = Me.tbl010Job.Columns.Add("JobNumber", ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Session is expiring immediately the page is loaded
    ... Protected WithEvents Tr1 As System.Web.UI.HtmlControls.HtmlTableRow ... Private Sub Page_Init(ByVal sender As System.Object, ... Dim BLProcIns As ProcessInspection ... ' Create a DataColumn and set various properties. ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: DataGridView.Columns.Add
    ... einem DataColumn, der nicht im DataGridView angezeigt wird. ... Dim drv As DataRowView = CType ... CurrencyManager und BindingSource sind für mich immer noch ...
    (microsoft.public.de.german.entwickler.dotnet.vb)
  • Re: Indexing tables by name is very slow
    ... If the datacolumn or table is the same for each iteration of the ... pointer before the loop and then use those in the loop. ... Dim PTableCol as DataColumn = FKTable.Columns ... For Each rRelation as DataRelation in FKTable.Rows ...
    (microsoft.public.dotnet.framework.adonet)