Binding a Datagrid to a query????

  • Thread starter Thread starter Darryn Ross
  • Start date Start date
D

Darryn Ross

Hi,

I am trying to bind a dg to a query but i keep getting the following error
message.. 'Cannot create a child list for field "MyQuery"'.

My code is as follows...

Ds.Clear() ;
Connection.ConnectionString = ConnectionPath ;
Connection.Open() ;
//Establishing the database connection and loading the datagrid
SelectCommand.CommandText = "MyQuery" ;
SelectCommand.Connection = Connection ;
SelectCommand.CommandType = CommandType.StoredProcedure ;
Adapter.SelectCommand = SelectCommand ;
Adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey ;
Adapter.Fill(ChartLstDs) ;
dg.SetDataBinding(Ds, "MyQuery") ; //Error occurs here???


Regards

Darryn
 
Clue: The name of the table is my query?

From what I see, set up a table mapping for the actual table name and use
that in databindings.

Adapter.TableMappings.Add("Table", "MyQuery");

Or simply use "Table" in the error line. You can examine the name of
Table[0] in your DataSet and asily confirm this.

You are on the right track, but the MyQuery (name of sproc) and the
DataTable name (what is bound to dg) are not the same name in what you are
showing.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside the box!
*************************************************
 
Back
Top