We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Displaying hierarchical data in a grid, using OleDbDataAdapters

Thread ID:





7155 Sep 14,2003 10:46 AM UTC Sep 15,2003 08:08 AM UTC WinForms 6
Tags: GridControl
Jennifer Bell
Asked On September 14, 2003 10:46 AM UTC

Am using OleDbDataAdapter to load 2 tables into a dataset. DataSource of grid is Dataset. The data appears to load in table, ie. can see the correct number of rows etc, but the data is invisible.. also grid doesnt display at all if I try and access an InternalColumn in the relationship. Code will make clear hopefully:- GridModel gridModel = this.gridDataBoundGrid1.Model; GridModelDataBinder gridBinder = this.gridDataBoundGrid1.Binder; System.Data.OleDb.OleDbDataAdapter db = new System.Data.OleDb.OleDbDataAdapter("select * from t_client", da.getConnection()); System.Data.OleDb.OleDbDataAdapter db2 = new System.Data.OleDb.OleDbDataAdapter("select * from t_clientExchange", da.getConnection()); db.Fill(this.ds, "t_client"); db2.Fill(this.ds, "t_clientExchange"); System.Data.DataRelation dr = new System.Data.DataRelation("Clients_Exchanges", this.ds.Tables["t_client"].Columns["clientID"], this.ds.Tables["t_clientExchange"].Columns["clientID"]); this.ds.Relations.Add(dr); this.gridDataBoundGrid1.DataSource = this.ds; this.gridDataBoundGrid1.DataMember = "t_client"; GridHierarchyLevel hlClients_Exchanges = gridBinder.AddRelation("Clients_Exchanges"); GridHierarchyLevel hlClients = gridBinder.RootHierarchyLevel; // when this line uncommnented the grid desont display at all GridStyleInfo exchangeIdStyle = hlClients_Exchanges.InternalColumns["exchangeID"].StyleInfo;

Administrator [Syncfusion]
Replied On September 14, 2003 12:59 PM UTC

Are you seeing any exceptions being displayed in the output window when you run this code? Where are you trying to execute this code? Is it in Form.Load, or at some point where an empty grid is already visible? Can you reproduce this problem in a sample using the northwind database, and attach it here?

Jennifer Bell
Replied On September 14, 2003 01:20 PM UTC

Output window gives this: 'DefaultDomain': Loaded 'c:\windows\microsoft.net\framework\v1.1.4322\mscorlib.dll', No symbols loaded. 'EuroConfig': Loaded 'C:\gui_datagrid\euroconfig\bin\Debug\EuroConfig.exe', Symbols loaded. 'EuroConfig.exe': Loaded 'c:\windows\assembly\gac\system.windows.forms\1.0.5000.0__b77a5c561934e089\system.windows.forms.dll', No symbols loaded. 'EuroConfig.exe': Loaded 'c:\windows\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll', No symbols loaded. 'EuroConfig.exe': Loaded 'c:\windows\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll', No symbols loaded. 'EuroConfig.exe': Loaded 'c:\windows\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll', No symbols loaded. 'EuroConfig.exe': Loaded 'c:\windows\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.dll', No symbols loaded. 'EuroConfig.exe': Loaded 'c:\windows\assembly\gac\syncfusion.grid\\syncfusion.grid.dll', No symbols loaded. 'EuroConfig.exe': Loaded 'c:\windows\assembly\gac\syncfusion.shared\\syncfusion.shared.dll', No symbols loaded. 'EuroConfig.exe': Loaded 'c:\windows\assembly\gac\_fusionlic\\_fusionlic.dll', No symbols loaded. FrmAddSomClient.gridDataBoundGrid1_ScrollInfoChanged(of 6, ) FrmAddSomClient.gridDataBoundGrid1_ScrollInfoChanged(of 6, ) The code I gave originally being called in Frm_load event. Running in Visual Studio .NET 2003. Connecting to a Sybase DB using Sybase client 12.5. When I look at thedataset through a dataset debugger, it looks ok - the relationship exists between the 2 tables etc. Dont know anything about NorthWind DB so cant switch over easily. thanks for your response.

Administrator [Syncfusion]
Replied On September 14, 2003 06:21 PM UTC

Here is a sample that seems to work with the northwind database using an OleDbAdapter. The data comes from an MDB file that we ship as sample data. (To run the sample, you may have to change the path if you did not install the Syncfusion controls on teh C drive in the default folders.)

Jennifer Bell
Replied On September 15, 2003 06:23 AM UTC

hiclay - thanks a lot for your example. I replaced your calls to NorthWind with my Sybase oledbadaptor calls and it works! Also the problem seems to be the following, when I try and all column headers the data disappears. Added for the parent row and left the child columns header free, the data was only displayed in child rows. Any ideas what I am doing wrong ? Code below. GridHierarchyLevel hlClients = this.gridDataBoundGrid1.Binder.RootHierarchyLevel;hlClients.LayoutColumns( new string[] { "ClientId","ClientName", "MaxNumberOrders", "MaxOrderQuantity", "MaxOrderValue", "BuyThresholdValue", "SellThresholdValue", }); hlClients_Exchanges.LayoutColumns( new string[] { "", "ExchangeId", "Salesman", "ContractingOffice","MaxNumberOrder", "MaxOrderQuantity", "MaxOrderValue", "BuyThresholdValue", "SellThresholdValue" }); thanks again.

Jennifer Bell
Replied On September 15, 2003 06:35 AM UTC

Ok, figured it ok - the Column names in Layout have to match the column names in the DB. How can I map these the column names in DB to column names I would actually want to display to users ? thanks alot

Administrator [Syncfusion]
Replied On September 15, 2003 08:08 AM UTC

You use the StyleInfo.HeaderText property in either level.GridBoundColumns or level.InternalColumns to set the displayed header text. In the sample, code like this works. GridHierarchyLevel level = this.gridDataBoundGrid1.Binder.AddRelation("CustomerToOrders"); level.InternalColumns["CustomerID"].HeaderText = "cust id";


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon