StrataFrame Forum

BO Populated combo boxes causing errors

http://forum.strataframe.net/Topic4511.aspx

By Andria Jensen - 11/15/2006

Since I upgraded to the latest version of SF, none of my combo boxes will populate.  This happens for all ComboBoxEdits that are set to populate by BO.  They were working before and now everytime a form with a combobox on it tries to load I get an error and the rest of the form quits loading.  I get an error with a stack trace like the following.  I also attached the SQL log from this morning.


11/14/2006 5:25:09 PM
Source: System.Data
Message: Column 'CurrencyType' does not belong to table .
Stack:    at System.Data.DataRow.GetDataColumn(String columnName)
   at System.Data.DataRow.get_Item(String columnName)
   at MicroFour.StrataFrame.UI.Windows.Forms.DevEx.ComboBoxEdit.PopulateFromDataTable()
   at MicroFour.StrataFrame.UI.Windows.Forms.DevEx.ComboBoxEdit.PopulateComboBox()
   at MicroFour.StrataFrame.UI.Windows.Forms.DevEx.ComboBoxEdit.set_DataSource(DataTable value)
   at MicroFour.StrataFrame.UI.Windows.Forms.DevEx.ComboBoxEdit.SetDataSource(Object DataSource, String DisplayMember, String ValueMember)
   at MicroFour.StrataFrame.UI.Windows.Forms.ListControl.PopulateComboFromBusinessObject(IListControl lstControl, Object[] Parameters)
   at MicroFour.StrataFrame.UI.Windows.Forms.ListControl.PopulateCombo(Control lstControl, Object[] Parameters)
   at MicroFour.StrataFrame.UI.Windows.Forms.DevEx.ComboBoxEdit.PopulateCombo(Object[] Parameters)
   at MicroFour.StrataFrame.UI.Windows.Forms.DevEx.ComboBoxEdit.Requery()
   at BBS.GUI.Tables.frmChkSourceTbl.frmChkSourceTbl_Activated(Object sender, EventArgs e) in C:\FactorSoftV3\BBS.GUI\Tables\frmChkSourceTbl.vb:line 11
   at System.Windows.Forms.Form.OnActivated(EventArgs e)
   at System.Windows.Forms.Form.set_Active(Boolean value)
   at System.Windows.Forms.Form.ActivateMdiChildInternal(Form form)
   at System.Windows.Forms.Form.WmMdiActivate(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

By StrataFrame Team - 11/15/2006

I'm not sure why you're getting this error because I just tested it and it worked fine on this end... what you might do is put a break point in the method that you're using to populate the business object (FillWhatever()).  And step through the method until the current line lands on the End Sub.  Then, check Me.CurrentDataTable within the Watch window and make sure that the CurrencyType column does actually exist on the table...
By Andria Jensen - 11/15/2006

Yep, did exactly what you said and it DOES have a CurrencyType field in there.  I have attached the screenshot so you can see what I mean.  This is happening on every combo box and I can't get to a lot of my forms to work.  Any other ideas?
By Trent L. Taylor - 11/15/2006

What version of DevExpress are you using?
By Andria Jensen - 11/15/2006

DevExpress version is 6.2.3
By Trent L. Taylor - 11/15/2006

First of all, we beleive you otherwise you would not be posting out here.  But neither of us have been able to reproduce this.  Could you create a small sample project, you could use the StrataFrameSample database if you would like, so that we might be able to see this in action.  Obviously there is something different between what you are doing and what we are doing or there is another element in the forumula.

Also, you are the first to report this as well, so I do not think it is a framework wide thing.  Otherwise, we would have already heard about this since the 1.5.1 release has been out for 3 weeks now.

So if you could help us work through your problem, that would be great.  We want to help, but we need more information.

By Andria Jensen - 11/15/2006

Ok, no problem.  I'll try to get together a sample project.  I figured this would be an interesting one to figure out.  I've looked through StrataFrame source code, my source code, and just haven't seen anything I could pinpoint as the cause.  Maybe a smaller project will shed some light on this.  Stay tuned Smile
By Trent L. Taylor - 11/15/2006

Great...thanks.
By Andria Jensen - 11/15/2006

I now get a different error after I set up a sample project.  I used the customers table and just put a customers BO in the project from the StrataFrameSample db.  I then set the PopulationDataSourceSettings on the ComboBoxEdit to use a FillAll method which I added to the BO.  When I load the form, I get an error which says: "Exception has been thrown by the target of an invocation."  Please check out the project I am attaching and tell me if I've done something wrong here.  I have also attached a screenshot of the error I get in case it does something different on your end.  Thanks in advance.
By Andria Jensen - 11/15/2006

Ok, I feel stupid now. My database wasn't pointing to the right place so that's why the invocation error.  I fixed it and it seems to populate from the Customers BO.  Let me try a couple of other things and see what I can come up with.
By Trent L. Taylor - 11/15/2006

Well, I had to change the database from MyTestDatabase to StrataFrameSample, but once I did this it worked just fine:

It was definitely not optimized and was really slow, but it worked.  In your exception window, what is the inner exception.  Click on Detail and go as deep as you can to see what the actual error is.

By Trent L. Taylor - 11/15/2006

Hehe It looks like we were posting at the same time Smile  Let me know if you can find anything else.
By Andria Jensen - 11/15/2006

Ok, I have attached a new project which illustrates the error I am getting.  I think I know what's happening here...On the combo box if I set the DisplayMember and/or ValueMember properties to anything it gives that error.  I know that you should let the PopulationDataSourceSettings take care of this, but I must be setting those properties on my combo boxes.   One question though...this was working just perfectly before, so is there something that changed that could have caused this error?
By Trent L. Taylor - 11/15/2006

Andria,

I think that there was something else before in the mix because you CANNOT change the DisplayMember and ValueMember of the combo.  When you use the PopulationDataSource settings, we create a temp ADO.NET table with two columns: Display and Value.  These are the only two columns in the data source associated with the combo.  So when you set it to cust_pk, it is telling you the truth, the field does not exist, nor has it ever.

If you want the value member to be something else, then set it in the PopulationDataSourceSetting.  This is what the Value Member setting in the PopulationDataSource settings is for:

If you want to have your own display and value members, then create your own data source and you can set the display and value member to whatever columns exist in your data source:

Dim loTable As New DataTable()

loTable.Columns.Add(...)

MyCombo.DataSource = loTable
MyCombo.DisplayMember = "MyDisplayField"
MyCombo.ValueMember = "MyValueField"

And just for the record, we had to extend the DevExpress combo to even support a data source and value member.  This is the most basic thing in the world and they did not even have it!!!  It took a full day or two to implement this on their control which was something that should have already existed.

By Andria Jensen - 11/15/2006

I agree that these properties should be getting setup in the PopulationDataSourceSettings, and they are.  I guess in my beginning days of using SF I didn't know what I was doing and was setting properties all over the place!  Now, I know better but it was just throwing me off since it was working before and all of a sudden it seemed like my whole app was crashing left and right on combo boxes.  Oh well, everything seems to be working now...I'll just have to go back and clean up my previous mistakes.  Thanks for helping me figure this out!  I appreciate the support you guys give us.
By Trent L. Taylor - 11/15/2006

I bet I know why it changed...it would have to do with the InitializeCOmponent() method.  Before, the ValueMember property was being set before the PopulationDataSourceSettings.  Sometimes when a rebuild is done it may re-order these if a form is modified...thus the time old initialization sequence problem. 
By Andria Jensen - 11/15/2006

Makes complete sense Trent.  I never thought of that...VS 2005 seems to do a lot of things in random order.  I've even been seeing my Activate event fire before my Load event!  Messes up everything.