The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

ComponentOne Combo

Last post 03-07-2007, 7:03 AM by David.Parsons. 25 replies.
Page 2 of 2 (26 items)   < Previous 1 2
Sort Posts: Previous Next
  •  02-23-2007, 9:40 AM 519 in reply to 518

    Re: ComponentOne Combo

    David,

    As you and Martin said, the best solution is:

    Code:
                With countiesCollection.Query
                    .Select(.CountyName, .Id)
                    .OrderBy(.CountyName.Ascending)
                    .Load()
                End With

    Declan
  •  03-06-2007, 1:22 PM 805 in reply to 519

    Re: ComponentOne Combo - Still in difficulty with this

    I have tried using 1.5.3 and

    EntitySpaces Version # 2007.0.0304.0

    MyGeneration Version # 1.2.0.2

    Code:
        Private collJudgments As JrMoneyJudgmentsCollection = New JrMoneyJudgmentsCollection
        Private collCounties As CountiesCollection = New CountiesCollection
    
        Private Sub frmJudgments_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Try
                collJudgments.LoadAll()
    
                With collCounties.Query
                    .Select(.Id, .CountyName)
                    .OrderBy(.CountyName.Ascending)
                    .Load()
                End With
    
                Me.JrMoneyJudgmentsCollectionBindingSource.DataSource = collJudgments
                Me.CountiesCollectionBindingSource.DataSource = collCounties

    Now fill the combo:

    Code:
                With Me.C1Combo1
                    .DataSource = Nothing
                    .DataSource = collCounties
    
                    .DisplayMember = CountiesMetadata.ColumnNames.CountyName
                    .ValueMember = CountiesMetadata.ColumnNames.Id
                    .DataBindings.Add(New System.Windows.Forms.Binding("selectedvalue", Me.JrMoneyJudgmentsCollectionBindingSource, jrmoneyjudgmentsmetadata.ColumnNames.CountyID , True))
                End With
    
      
    Code:
                With Me.CountyNameComboBox
                    .DataSource = Nothing
                    .DataSource = collCounties
                    .DisplayMember = CountiesMetadata.ColumnNames.CountyName
                    .ValueMember = CountiesMetadata.ColumnNames.Id
                    .DataBindings.Add(New System.Windows.Forms.Binding("SelectedValue", JrMoneyJudgmentsCollectionBindingSource, jrmoneyjudgmentsmetadata.ColumnNames.CountyID, True))
                End With

    The standard combobox will display the correct text in the text box portion of the combo. The ComponentOne combo does not.

    Now if I use NorthWind

    Code:
    Private collOrders As BusinessObjects.OrdersCollection = New BusinessObjects.OrdersCollection
    Private collCustomers As BusinessObjects.CustomersCollection = New BusinessObjects.CustomersCollection
    
                collOrders.LoadAll()
    
                With collCustomers.Query
                    .Select(.CustomerID,.CompanyName )
                    .OrderBy(.ContactName .Ascending)
                    .Load()
                End With
    
                Me.bsOrders.DataSource = collOrders
                Me.bsCustomersCollection.DataSource = collCustomers
    

    Code:
                With Me.CompanyNameComboBox
                    .DataSource = Nothing
                    .DataSource = collCustomers
                    .DisplayMember = CustomersMetadata.ColumnNames.CompanyName
                    .ValueMember = CustomersMetadata.ColumnNames.CustomerID
                    .DataBindings.Add(New System.Windows.Forms.Binding("SelectedValue", bsOrders, OrdersMetadata.ColumnNames.CustomerID, True))
                End With
    Code:
                With Me.C1Combo1
                    .DataSource = Nothing
                    .DataSource = collCustomers
    
                    .DisplayMember = CustomersMetadata.ColumnNames.CompanyName
                    .ValueMember = CustomersMetadata.ColumnNames.CustomerID
                    .DataBindings.Add(New System.Windows.Forms.Binding("SelectedValue", bsOrders, OrdersMetadata.ColumnNames.CustomerID, True))
                End With

    All works as expected for both the standard combo and ComponentOne Combo. This suggests the problem is not ComponentOne Combo and leads me to think there is something in the tables causing difficulty.

    This is my county table:

    Code:
    /****** Object:  Table [dbo].[counties]    Script Date: 03/06/2007 21:10:34 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[counties](
    	[ID] [int] IDENTITY(1,1) NOT NULL,
    	[CountyName] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    	[CountyCode] [nvarchar](2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    	[SelectionTypeID] [int] NULL,
    	[aka] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    	[TimeStamp] [timestamp] NULL,
     CONSTRAINT [PK_counties] PRIMARY KEY CLUSTERED 
    (
    	[ID] ASC
    )WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF, FILLFACTOR = 90) ON [PRIMARY]
    ) ON [PRIMARY]

     

    and  the parent table:

    Code:
    /****** Object:  Table [dbo].[jrMoneyJudgments]    Script Date: 03/06/2007 21:19:08 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[jrMoneyJudgments](
    	[ID] [int] IDENTITY(1,1) NOT NULL,
    	[RecordType] [int] NULL,
    	[CountyID] [int] NULL,
    	[CourtID] [int] NULL,
    	[FirstName] [nvarchar](100) COLLATE Latin1_General_CI_AI NULL,
    	[Surname] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    	...
    	[timestamp] [timestamp] NOT NULL,
     CONSTRAINT [PK_jrMoneyJudgments] PRIMARY KEY CLUSTERED 
    (
    	[ID] ASC
    )WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    
    GO
    ALTER TABLE [dbo].[jrMoneyJudgments]  WITH CHECK ADD  CONSTRAINT [FK_MoneyJudgements_Courts] FOREIGN KEY([CourtID])
    REFERENCES [dbo].[jrCourts] ([courtID])
    GO
    ALTER TABLE [dbo].[jrMoneyJudgments] CHECK CONSTRAINT [FK_MoneyJudgements_Courts]

     

    Initially I had a link between these on CountyId > id but removed it in testing.

    What am I missing? All suggestions welcome.

    Declan

  •  03-06-2007, 2:03 PM 813 in reply to 805

    Re: ComponentOne Combo - Still in difficulty with this

    Try binding to the PropertyNames rather than the ColumnNames. They are the same in your Northwind test, but it looks like ID is getting PascalCased to Id.

    Also, this looks very strange - jrmoneyjudgmentsmetadata. How did that end up not PascalCased?

    Your first binding has "selectedvalue" instead of "SelectedValue".


    David Neal Parsons
    www.entityspaces.net
  •  03-06-2007, 3:06 PM 814 in reply to 813

    Re: ComponentOne Combo - Still in difficulty with this

    David,

    I've tried that and even changed the field in SQL to Id. However should the case not matter in VB. C# is case sensitive but not VB.

    The screen shot below shows what is happening. The County Name combo is a standard combo not used in this demo. County ID textbox shows the value of the CountyID in the judgment table. You can see that the combo is loaded with the data but for some reason it does not seem to bind with the "selected value".

    If I bind to text:

    .DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.JrMoneyJudgmentsCollectionBindingSource, "CountyID" , True))

    it will show the id value in the combo text box. 

    Declan

  •  03-06-2007, 3:23 PM 815 in reply to 814

    Re: ComponentOne Combo - Still in difficulty with this

    Now for the really weird bit:

    Code:
               With Me.CountyNameComboBox
                    .DataSource = Nothing
                    .DataSource = collCounties
                    .DisplayMember = CountiesMetadata.ColumnNames.CountyName
                    .ValueMember = CountiesMetadata.ColumnNames.Id
                    .DataBindings.Add(New System.Windows.Forms.Binding("SelectedValue", JrMoneyJudgmentsCollectionBindingSource, jrmoneyjudgmentsmetadata.ColumnNames.CountyID, True))
                End With
    
                With Me.C1Combo1
                    .DataSource = Nothing
                    .DataSource = collCounties
    
                    .DisplayMember = CountiesMetadata.ColumnNames.CountyName
                    .ValueMember = CountiesMetadata.ColumnNames.Id
                   
                End With
     

    Note, the SelectedValue on the C1Combo is not bound. With this the 2 combo boxes will display correctly but this seems to cause other problems.

     

    I am afraid this is beyond me Sad

    Declan

  •  03-06-2007, 3:46 PM 817 in reply to 815

    Re: ComponentOne Combo - Still in difficulty with this

    Now we are getting places Smile

    I changed the data type of the CountyID field in judgments table and the ID field in Counties table from int to nchar(5) and it worked. Why???

    OK, so that is a workaround. I need to be able to use int to link the tables. Any suggestions?

     

    Declan

  •  03-06-2007, 5:35 PM 818 in reply to 817

    Re: ComponentOne Combo - Still in difficulty with this

    Declan, I'm hoping that our coming data-binding support clears this all up. But let's give a hip-hip hooray for these Community Server forums, it's a joy to read along with such well formatted posts.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  03-07-2007, 1:59 AM 823 in reply to 818

    Re: ComponentOne Combo - Still in difficulty with this

    Mike,

    I'm not particularly interested in pretty formatted code with Community Server.

    This problem has cost me dearly and I am currently wondering if my commitment to ES was worth the effort. Yes ES has lots going for it, including support here, but I am not sure if I can risk running into something else further down the line that might prove to be a show stopper. This is the danger of using third party products. On one side they can save lots of time and effort but on the down side you can run into difficulty that could cost you a project. The jury is out on this one Sad Perhaps I myself am guilty of not evaluating enough before comitting to using ES on this project.

    I have done further testing on this issue which seems to point directly at Entity Spaces. Would you agree?

    • EntitySpaces with NorthWind Orders - Customers (link fields are nchar(5)). This works
    • EntitySpaces with my own tables (link fields are nchar(5)). This works
    • EntitySpaces with my own tables (link fields are int). This does not work
    • EntitySpaces with my own tables (link fields are int). This works.  (Standard ComboBox)
    • DataSet with NorthWind Orders - Customers (link fields are nchar(5)). This works
    • DataSet with my own tables (link fields are int). This works

    When I say it works I mean that the Component One Combo behaves as expected. The only test that fails is with ES and a Component One ComboBox where the link fields are of type int.

    Have you any thoughts as to what might be wrong or better still a timescale for a fix? Today?Wink

    Declan

  •  03-07-2007, 5:22 AM 826 in reply to 823

    Re: ComponentOne Combo - Still in difficulty with this

    Hi Declan

    I meant to have a look at this last night (as I'm a nosey so-and-so and thought I might learn something from it in the process) but didn't get a chance.  Looking at the C1 forums, might it be anything to do with the following http://helpcentral.componentone.com/cs/forums/190065/ShowPost.aspx (it appears that the latest version can't use a number for valuemember so that may explain things)?

    It might not be that, but it's another possible avenue?

    Cheers

    Martin

  •  03-07-2007, 5:36 AM 829 in reply to 826

    Re: ComponentOne Combo - Still in difficulty with this

    Hi Martin,

    Yes I saw that but it does not seem to apply in this case. However I am using the latest build of the C1 control. The code below works fine and the CountyID and ID fields are both of type int.

     

    Code:
     Private ds As DataSet
    
    
        Private Sub frmDataSet_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            ds = loadData()
            showData()
        End Sub
    
        Private Sub showData()
    
            Try
                Me.bs.DataSource = ds.Tables("Judgments")
                Me.bn.BindingSource = bs
    
                Me.FirstNameTextBox.DataBindings.Add("Text", bs, "FirstName")
                Me.SurnameTextBox.DataBindings.Add("Text", bs, "Surname")
                Me.CountyIDTextBox.DataBindings.Add("Text", bs, "CountyID")
    
    
                With Me.C1Combo1 
                    .DataSource = ds.Tables("Counties")
                    .DisplayMember = "CountyName"
                    .ValueMember = "ID"
                    .DropDownWidth = 200
                    .DataBindings.Add(New System.Windows.Forms.Binding("SelectedValue", bs, "CountyID" , True))
                End With
    
    
            Catch ex As Exception
                MessageBox.Show(ex.Message)
    
            End Try
    
    
        End Sub
    
        Private Function loadData() As DataSet
    
            Dim cn As String = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=TestDb;Data Source=MyServer"
    
            Dim sqlJudgments As String = "select * from jrMoneyJudgments ORDER BY ID"
            Dim sqlCounties As String = "select id, CountyName  from counties ORDER BY CountyName"
    
            Try
    
                Dim daJudgments As New SqlDataAdapter(sqlJudgments, cn)
                Dim daCounties As New SqlDataAdapter(sqlCounties, cn)
    
                Dim ds As New DataSet("JudgmentsCounties")
    
                daJudgments.Fill(ds, "Judgments")
                daCounties.Fill(ds, "Counties")
    
                Return ds
    
            Catch ex As Exception
                MessageBox.Show(ex.Message)
                Return Nothing
    
            End Try
    
        End Function
    

    Declan

  •  03-07-2007, 7:03 AM 834 in reply to 829

    Re: ComponentOne Combo - Still in difficulty with this

    As a work-around for the C1Combo, try setting the DataSource to Query.LoadDataTable, and the other properties as you do for the DataSet.

    Code:
    collJudgments.LoadAll()
    
    With collCounties.Query
    	.Select(.Id, .CountyName)
    	.OrderBy(.CountyName.Ascending)
    End With
    
    Me.JrMoneyJudgmentsCollectionBindingSource.DataSource = collJudgments
    Me.CountiesCollectionBindingSource.DataSource = collCounties.Query.LoadDataTable()
    		
    
    With Me.C1Combo1 
    	.DataSource = CountiesCollectionBindingSource
    	.DisplayMember = "CountyName"
    	.ValueMember = "ID"
    	.DropDownWidth = 200
    	.DataBindings.Add(New System.Windows.Forms.Binding("SelectedValue", bs, "CountyID" , True))
    End With

    David Neal Parsons
    www.entityspaces.net
Page 2 of 2 (26 items)   < Previous 1 2
View as RSS news feed in XML