By Terry Bottorff - 8/20/2009
I am using the latest version of DevExpress and SF in VS 2008. I created a BO and just by using a break point I found that it does have data in it. I also created a Custom Business Binding Source and put in the code so it does appear on my toolBox. I dropped the BO and the BBS on my form. I also have placed a DevExpress Grid on my form.
Using the little black arrow on the top right of the grid(forgot what it is called) I did the following steps:
1. Choose Data Source.
2. Add Project Data Source.
3. Choose Object as data type.
4. Found my BOLib, found my BBS and selected it.
5. It immediately created the databindingsource and put the columns that I want in the grid.
6. I looked at the columns and they have the correct field names in them.
7. Because of #5 and #6 I think the grid is set up correctly?????
8. Run project and the grid shows with the column titles but no data.
What am I missing? TIA.
|
By Trent L. Taylor - 8/20/2009
Sounds like you did fine. Have you looked at the Grid sample that comes with SF? It isn't using a DevExpress grid, though I do think that one of the SF DevExpress samples does have a grid in it which might help as well.
|
By Terry Bottorff - 8/20/2009
I am having a problem loading the example. All kinds of errors. I will work on that. One thought, I don't have to load data in the BBS do I if I loaded data in the BO?
Also, anyone else got any ideas? TIA.
|
By Terry Bottorff - 8/21/2009
When I select the data source for the DevExpress Grid does it matter where I select the data source from:
Project Data Source?
Form List Instance?
Add Project Data Source and Select Object?
Also, is there a way to view the data in the BBS with the visualizer like you can in the BO?
Yuck I am having about as much fun with this as I can stand......
|
By Terry Bottorff - 8/21/2009
This is plumb dumb. It can not be this hard. I just created a simple project with a form, BO, and BBS. With a break point I know the BO has data with the visualizer. I add a DevExpress Grid and select the data source which is my BBS. It populates the columns with the correct fields. When I run it I get NO DATA. What property do I need to set?
|
By Peter Jones - 8/21/2009
Hi Terry,
I think you need to be looking at this at run-time. Why not add a button to your form and break when its clicked. You can then look at your grid and its data source in 'real-time' to see what the status is. I can only figure that your BO is empty.
Cheers, Peter
|
By Terry Bottorff - 8/21/2009
That is exactly what I did. I click the button. Use me.mybo.currentview and use the watch window and the visualizer and I have 311 records. Yet the grid shows absolutely nothing. I'm overlooking something or some switch and I know it but i'll be D...... if I know what it is???? TIA.
|
By Peter Jones - 8/22/2009
Hi Thomas,
Yes but the grid is displaying data from the business binding source (bbs) for the bo not the bo itself. Does the bbs' current view contain data?
Cheers, Peter
'
|
By Terry Bottorff - 8/23/2009
On my break point I tried this in the Watch Window:
me.myBBS.CurrentView but I could find that.
So I tried me.myBBS.SourceBO.CurrentView and it had Zero(0) Records.
If that is where I should have looked then no wonder the grid has no records. But is that where I should have looked? If so what could I have done wrong in setting up the BBS? Setting up a BBS seems to be so straight forward.
If these are goofy questions I am sorry but I'm a newbie to Strataframe which of course makes me a real newbie to DevExpress.....
|
By Peter Jones - 8/23/2009
Hi Terry (sorry about the Thomas),
In the Watch Window you should be able to see:
Me.MyBBS.BusinessObject.CurrentView.
This is the data your grid is using
The first path under BusinessObject should be the name of the BO that populates the BBS. If this as expected?
You can the drill down into the BO (in Me.MyBBS.BusinessObject.YourBOName) itself to see what it says about its data source and all its controls.
Do you use the BO's ParentFormLoading event to populate your BO when the form opens?
Cheers, Peter
|
By Trent L. Taylor - 8/24/2009
Terry,
You are correct in that it should not be this difficult, so most likely, I have learned from experience, there is probably something simple not being done. I have attached a C# simple sample using a BO, BBS, and a DevEx grid (v8.2, you may need to update your references to make this sample work).
|
By Terry Bottorff - 8/24/2009
Peter first I want to thank you for the help you are offering.
I put Me.MyBBS.BusinessObject.CurrentView in the watch Window and used the visualizer.....NO DATA?????? So obviously no data in the grid....?
This the my code for the form. I tried loading the data in the load and the new.
me.customers1.currentview Shows all the records in the sample customers database since all I did was a "Select * from customers".
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Customers1.fillalldata()
End Sub
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
'Me.Customers1.fillalldata()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Break Point
End Sub
End Class
Scanning under my BBS I did run into this info which does not seem correct to me but I don't know how to fix it or if it is even wrong?????
CurrentRow{"The CurrentRow for table '[dbo].[Customers]' could not be evaluated because the CurrentRowIndex is out of range. Business object record count: 0. CurrentRowIndex: -1."}System.Data.DataRow
TIA.
|
By Trent L. Taylor - 8/24/2009
Terry, did you download my sample and see if it worked in your development environment?
|
By Terry Bottorff - 8/24/2009
Op's Trent I missed your reply this morning. I will look at the sample. Thank you so very much........ I will get back to you.
|
By Trent L. Taylor - 8/24/2009
No problem, just wanted to make sure that it worked. Thanks.
|
By Terry Bottorff - 8/24/2009
I replaced all the references from 8.2 to 9.1 and rebuilt the solution. I run and I get this error? I also replaced the grid with the new 9.1 grid.
Remember I am not very good at this yet.....
ApplicationException
An error occurred while creating the main form
TargetInvocationException
Exception has been thrown by the target of an invocation.
FileNotFoundException
Could not load file or assembly 'DevExpress.XtraGrid.v8.2, Version=8.2.8.0, Culture=neutral, PublicKeyToken=9b171c9fd64da1d1' or one of its dependencies. The system cannot find the file specified.
Source : MicroFour StrataFrame UI
Stack Trace:
at DevExGrid.Form1.InitializeComponent()
at DevExGrid.Form1..ctor() in c:\Temp\DevExGrid\DevExGrid\Form1.cs:line 21
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at MicroFour.StrataFrame.Application.StrataFrameApplication.RunApplication()
|
By Trent L. Taylor - 8/24/2009
Well, you still have 8.2 references in either the designer file or the licenses.lic file (or both) which is producing this error. I have sent an email to DevExpress about giving us another license to work with so that I can get on 9.1. We have been seeing a lot more errors since some of our users have moved over to 9.1, so if I get the newer license, then I will recompile the sample and re-post it.
|
By Terry Bottorff - 8/24/2009
OK thanks.........
|
By Peter Jones - 8/24/2009
Hi Terry,
The call Me.Customers1.fillalldata() should be in the ParentFromLoading event of your BO. This way, whenever you drop the BO onto a form, it will just 'fill'. The way you have it at the moment you will need to execute Me.Customers1.fillalldata() in every form that is using the BO. So, why don't you make that change anyway but I don't know that it will help your problem much.
I would then put a breakpoint on the line and see what the status is after fillalldata runs. On the question of fillalldata this is obviously custom code - are you sure it works?
Why don't you try the basic SF method of: Me.Customers1.FillDataTable("put your Select * code in here") to see what happens.
Cheers, Peter
|
By Terry Bottorff - 8/25/2009
Alright here is what my ParentFormLoading looks like:
Private Sub Customers_ParentFormLoading() Handles Me.ParentFormLoading
Me.FillDataTable("select cust_lastname,cust_firstname from customers order by cust_lastname")
End Sub
I put a break point on the "me" statement and after I continued one line in the watch window I put:
me.currentview and looked at the visualizer and it had the data. I could not find out how to look at the BBS data there. Is there a way? Then I continued back to the form and the gird had No Data..... I still had a break point on the click of a button and I looked at these:
me.customers1.currentview and it had data.
me.customersBBS!.BusinessObject.Currentview and it had NO DATA.
Again thank you for all the help and time.
|
By Peter Jones - 8/25/2009
Hi Terry,
In the properties of your BBS "BusinessObject" needs to point to the BO that contains the data - does it?
Also in the line "me.customersBBS!.BusinessObject.Currentview and it had NO DATA" I see that there is an explanation point after BBS - is this just a typo in your post or something more meaningful?
Cheers, Peter
|
By Terry Bottorff - 8/26/2009
I could not find any properties in the actual BBS that pointed at the BO.
The properties of the BBS instance on the form shows all of the columns of the BO But I don't see that it points directly at the BO with it's name in some property. Also, the ! was a keyboard mistake or a frustration mistake. Sorry about that.
Since I put the BBS on my toolbox and drug it to the form I don't need a statement like this do I? But if I do where would it be put?
Dim myBBS as customersBBS
|
By Peter Jones - 8/26/2009
Hi Terry,
"I could not find any properties in the actual BBS that pointed at the BO."
That's interesting because to associate a BBS to a BO you do need to know this (well, the way we do it we do). The process we use which I believe is normal is:
1) Create your BO's which are normally associated with single table and can contain custom columns.
2) Use the BO's by dropping them on forms as needed.
3) Then, for each BO that you want to use in DX grid drop a SF BBS onto the form.
4) When the BBS lands on the form this automatically opens the BBS' property sheet in Solutions Explorer.
5) In the property sheet there is a property called BusinessObject.
6) Open the combo box in BusinessObjects and you are given the the list of BO's on the form. Simply choose one and that's it.
7) Now make the BBS the data source for your grid.
Note: if you delete your BBS for some reason and recreate it it will no nolonger be the data source for your grid. It gets removed when the BBS is deleted.
Cheers, Peter
|
By Trent L. Taylor - 8/27/2009
Just FYI, I have download the 9.2 build of DevExpress and I will re-compile the sample and re-post it this evening. I am out of the office today, but I will get this posted with the new DevExpress version so that you don't have to worry with references.
|
By Terry Bottorff - 8/27/2009
Thank you so much.
|
By Terry Bottorff - 8/27/2009
Peter: I followed your step by step outline. I created a new project and I added a maintenance form just so I could check the BO Data. I did not know you could drag a drop a BBS to your form so I did learn something there ( always just added a new item to the project and then put it on the toolbox and drug it to the form). I did get the property BusinessObject and set it like you said in #5. I set the data source in the devgrid to my BBS. Ran the program and now on every field I get the following error on the Public Property [each field] as ..... :
Get
return ctype(me.currentRow.Item("cust_Prefix"),system.string) =error received=>Column 'cust_prefix does not belong to table Customer.
end get
I know it is every field because I went into the devgrid and deleted the first field and then the error on that field went away. Then I deleted the next column and then the error went away.... and so forth?
If I run the project without the devgrid it runs even with the BBS on the form but just not attached to anything?
I have just about had it. I think I will uninstall SF and reinstall and see what happens. It is almost like I have a corrupted ????? somewhere and the BO and BBS are not talking or something.....?
|
By Terry Bottorff - 8/27/2009
OK I now have uninstalled and reinstalled SF to the latest version. Now I create a simple maintenance form, connect to customers with a BO. Put two text boxes and BO on form with binding source to the cust_lastname and cust_firstname.
Run the project and it all loads and the navigation buttons work. Try to Edit and I now get this error?????
BusinessLayerException
An error occurred while saving an the data to the server.
DataLayerSavingException
Cannot create UPDATE command because the updating DataTable does not contain columns for all PrimaryKeyFields.
DataLayerException
Cannot create UPDATE command because the updating DataTable does not contain columns for all PrimaryKeyFields.
Source : MicroFour StrataFrame Business
Stack Trace:
at MicroFour.StrataFrame.Data.DataLayer.BuildUpdateInfo(DataTable UpdatingTable, Boolean Transactional, String TransactionKey)
at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTableThread(Object ThreadParams)
at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTable(DataTable TableToUpdate, Boolean Transactional, String TransactionKey)
at MicroFour.StrataFrame.Data.DataLayer.SaveByForm(DataTable TableToSave, Boolean Transactional, String TransactionKey)
at MicroFour.StrataFrame.Business.BusinessLayer.SaveByForm(Boolean Transactional, String TransactionKey)
at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save(Boolean Transactional, String TransactionKey)
at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save()
at MicroFour.StrataFrame.UI.Windows.Forms.MaintenanceFormToolStrip.cmdSave_Click(Object sender, EventArgs e)
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.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)
I ignored this error by not editing anything and I put the DevExpress Grid on. I put a BBS on and connected it to my BO in the properties. Set the datasource of the grid to my BBS. Run the form and I still get NO DATA in the Grid. So now I have at least 2 problems. Why do I get the above error and still no data in grid????
|
By Peter Jones - 8/27/2009
Hi Terry,
I wonder if there is something pretty basic here. Follow these steps to create a BO and get it into form:
Open your project
Right click on your Project Name
Select Add > New Item
Click SF Business Object
Click StrataFrame in the VS Menu Bar
Click Business Object Mapper
Go to your Project Name and expand
Select your new BO
In right hand panel click Configure Business Object
Select a source etc
When done right click on the BO in left panel and select Build Partial
Close the BO mapper
OPen the new BO
Create the ParentFormLoading event handler
Add some code to fill the BO
Close the BO
Build your project
Open your form
Drop the BO on the form
Drop a BBS on the form and follow the previous instructions
When done this way does it work?
Cheers, Peter
|
By Peter Jones - 8/27/2009
Hi Terry,
BTW - sorry for the delay in responding - we are obviously in very different time zones.
Cheers, Peter
|
By Terry Bottorff - 8/27/2009
I realized the time difference but I appreciate ALL the help. I am not under the gun so that is not a problem but it is just so frustrating when it should just WORK. I'll try your steps tomorrow and let you know the outcome. TIA.
|
By Trent L. Taylor - 8/28/2009
Terry,
Attached is the exact same sample compiled with the most recent version of DevExpress (9.2.4). The ONLY change that I had to make to this sample for it to run is change the references and the lic file, recompile, and it worked.
Please review this sample as this should get you going. Thanks.
|
By Terry Bottorff - 8/29/2009
I'll try it and let you know. Thank you very much.
|
By Trent L. Taylor - 8/29/2009
No problem.
|
By Terry Bottorff - 8/31/2009
I wish I could say No Problem but I can not..... Now I get this error. I have rebuilt the partial, I have gotten v9.2 of devexpress, I have the latest version of SF. I get absolutely no errors when I rebuild the project and it says the partial are rebuilt with no errors but I get this when I run the project:?
ApplicationException
An error occurred while creating the main form
TargetInvocationException
Exception has been thrown by the target of an invocation.
SqlException
Cannot open database "StrataFrameSample" requested by the login. The login failed.
Login failed for user 'TERRY-143C60421\Terry'.
Source : MicroFour StrataFrame UI
Stack Trace:
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at MicroFour.StrataFrame.Data.DbDataSourceItem.GetDataTable(DbCommand Command, OnChangeEventHandler CallBack)
at MicroFour.StrataFrame.Data.SqlDataSourceItem.GetDataTable(DbCommand Command, OnChangeEventHandler CallBack)
at MicroFour.StrataFrame.Data.DbDataSourceItem.GetDataTable(String Statement, OnChangeEventHandler CallBack)
at MicroFour.StrataFrame.Data.DataLayer.GetDataTable(String Statement, Boolean RegisterNotification)
at MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(String SelectStatement)
at DevExGrid.CustomersBO.FillTop100() in D:\VSProjects\DevExGrid\DevExGrid\CustomersBO.cs:line 82
at DevExGrid.Form1..ctor() in D:\VSProjects\DevExGrid\DevExGrid\Form1.cs:line 24
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at MicroFour.StrataFrame.Application.StrataFrameApplication.RunApplication()
I can not imagine why login failed for me. I can use SQL Server Management and look at the data when I login the same way??????
|
By Trent L. Taylor - 8/31/2009
Well, the good news is that this is 100% on the connection side. This error is genuine as I have never seen this message to date when it truly cannot connect to SQL. Check the following:
1. That the server is up and running
2. That the named instance is correct
3. You have the proper login credentials
4. If none of the above works, open the program.cs and change the Applicationkey to something other than StrataFrameSample and it will force the connection string wizard to come back up again and allow you to reset your connection.
|
By Terry Bottorff - 8/31/2009
All right it Works but what I had to do is stop using the machine I was using and moving too another of my laptops. Apparently the connection to the SQLExpress server is somehow hosed or something. I have not tried your suggestions yet but I will and report back.
I do have SqlExpress 2005 and 2008 on that other machine (that does not work) and I use both instances but the strataframesample is attached to the 2008 instance. Could there be something that let's SF look at the 2005 instance even though I tell it that sqlexpress2008 is the instance? I will try and attach to one of my other databases and see what happens with it...............
Trent and Peter thanks for all of your help. At least I know how to get the DevExpress Grid to work now. I did create my own project on my other laptop and it did work also. I just was too lazy to change the ethernet dongle.......
At least I was able to follow directions and make it work which makes me feel better.
|
By Terry Bottorff - 9/1/2009
When I started playing with the DevExpress Grid I put in the RowUpdated the following to update the data:
Me.CustomersTableAdapter.Update(Me.DSCustomers.Customers)
but how do I do it using a Strataframe BBS? TIA.
|
By Trent L. Taylor - 9/1/2009
Terry,
This post confuses me as the sample I posted SHOWs how to use an SF BBS with a DevExpress grid. At this point I am unsure of what you are getting at. Please provide more details. Thanks.
|
By Terry Bottorff - 9/1/2009
I'm sorry but I did not find any code in your example to save the data? So if I am correct all of that is handled behind the scene with the BO and BBS??? In my project that did not seem to work.
|
By Terry Bottorff - 9/1/2009
I got it all working.
Thank you so very much. Now to my other machine to see what is going on there?
Thanks for all your time and energy.
|
By Trent L. Taylor - 9/2/2009
I am just scanning through the posts this morning. If you still need help let me know, but it looks like you are on the track of getting things taken care of at this point. Glad you got it going.
|
By Terry Bottorff - 9/8/2009
Yes I did get it. Thanks.
|