Vikram Saxena
|
|
Group: Forum Members
Posts: 41,
Visits: 99
|
Dear All,i am using Starta Frame on my machine. everything is running quite well on machine. Our one more developer is also working on the same project as i am. but when he started the project on his machine a DataAccessLayer Exception is being thrown on his machine with the message that "An error occurred whuke creating a new DataLayer for the Business object." The inner exception is null. The other information i found for exception is "DataSourceKey [] is not defined." please tell me whats the wrong happening here? my code is in C# and SetDataSource event handler for the StartaFrame.SetDataSource event is as follows (present in program.cs) static void StrataFrameApplication_SetDataSources(){ ConnectionManager.ApplicationKey = "ISOCOM Key"; ConnectionManager.ApplicationDefaultTitle = "ISOCOM Connection"; ConnectionManager.ApplicationDefaultDescription = "This application connection is used by ISOCOM"; // Set the required data source information so that the ConnectionManager can gather it // SQL ConnectionConnectionManager.AddRequiredDataSourceItem("ISOCOM Key", "SQL Connection", DataSourceTypeOptions.SqlServer, "ISOCOM", "This connection is used by MyApplication.", true);////SQL Connection//// Make the call to SetConnections which will gather the connection information, show the connection wizard//// if needed and set the DataSources collection on the DataLayer class.ConnectionManager.SetConnections();}
|
|
|
StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
The problem is in the AddRequiredDataSourceItem() line. The first parameter is the DataSourceKey for the data source your requiring. It's basically a unique key for the connection string that will be created at runtime. That value must match the DataSourceKey property on each business object that will use that connection string. So, the business objects' DataSourceKey property defaults to an empty string (""), so either, you need to change that first parameter to an empty string, or you need to change the DataSourceKey property on your business objects to be "ISOCOM Key".
|
|
|
Fabian R Silva, -
|
|
Group: StrataFrame Users
Posts: 153,
Visits: 1.2K
|
I try to use 2 sql databases, but cannot make it work
Private Shared Sub SetDataSources()
'------------------------------------
' Using the Connection Manager
'------------------------------------
'-- Set the information specific to this application and the data sources
' The application key:
ConnectionManager.ApplicationKey = "Integra4"
ConnectionManager.ApplicationDefaultTitle = "Integra4"
ConnectionManager.ApplicationDefaultDescription = "conexion de Integra4"
'ConnectionManager.ShowAvailableConnectionStrings()
'-- Set the required data source information so that the ConnectionManager can gather it
' SQL Connection
'i4net
ConnectionManager.AddRequiredDataSourceItem("I4", "SQL Connection", _
DataSourceTypeOptions.SqlServer, "I4NET", "This connection is used by INTEGRA4.")
'Integra4Config
ConnectionManager.AddRequiredDataSourceItem("I4CONFIG", "SQL Connection", _
DataSourceTypeOptions.SqlServer, "Integra4Config", "Conexion a integra4Config")
ConnectionManager.SetConnections()
'-- ToDo: Set the data source key for the security tables
SecurityBasics.SecurityDataSourceKey = "I4"
End Sub
note: I try DataLayer.DataSources.Add(New SqlDataSourceItem("", "myconnectionstring")) but when I create a BO with a datasourcekey "integra4config" and make a fill, only a innerexception "The DataSourceKey [I4CONFIG] is not defined." appears I Cannot set 2 databases and call 2 BOs with diferent datasourcekeys Any help please?? thanks - Fabian
|
|
|
Fabian R Silva, -
|
|
Group: StrataFrame Users
Posts: 153,
Visits: 1.2K
|
StakTrace:
en MicroFour.StrataFrame.Business.BusinessLayer.get__DataLayer()
en MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(DbCommand CommandToExecute)
en Integra4BOLibrary.MenuesBO.FillbyModulo(String Modulo) en C:et\Integra4BOLibrary\MenuesBO.vb:línea 87
en Integra4.Menu.SetearMenu() en C:et\integra4\Formularios\Menu.vb:línea 22
en Integra4.Menu.Menu_Load(Object sender, EventArgs e) en C:et\integra4\Formularios\Menu.vb:línea 14
en System.EventHandler.Invoke(Object sender, EventArgs e)
en System.Windows.Forms.Form.OnLoad(EventArgs e)
en MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.OnLoad(EventArgs e)
en System.Windows.Forms.Form.OnCreateControl()
en System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
en System.Windows.Forms.Control.CreateControl()
en System.Windows.Forms.Control.WmShowWindow(Message& m)
en System.Windows.Forms.Control.WndProc(Message& m)
en System.Windows.Forms.ScrollableControl.WndProc(Message& m)
en System.Windows.Forms.ContainerControl.WndProc(Message& m)
en System.Windows.Forms.Form.WmShowWindow(Message& m)
en System.Windows.Forms.Form.WndProc(Message& m)
en System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
en System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
en System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
|
|
|
StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
The DataSourceKey that is the first parameter in the New SqlDataSourceItem should match the data source key that you set on your business objects. Try this and see if it works: Comment out everything in the SetDataSources() method (don't use the ConnectionManager) and put this: DataLayer.DataSources.Add(New SqlDataSourceItem("", "connection string to I4Net database")) DataLayer.DataSources.Add(New SqlDataSourceItem("I4CONFIG", "connection string to integra4Config database")) The first data source, I would leave with a DataSourceKey of an empty string because that is the default that the business objects use. The second one, use a new key, like the "I4CONFIG" and set the DataSourceKey on the business objects that need to talk to it to that value.
|
|
|
Fabian R Silva, -
|
|
Group: StrataFrame Users
Posts: 153,
Visits: 1.2K
|
Hello, thanks for reply I tested everything....except set 1 db with key '' and another with 'integra4config0 :/ it worked #1 question: I have to set 1 datasourcekey with empty value (''), it is required? when I set 2 db, both with datasourcekey, the error appears, when I set 1 db with an empty datasourcekey and other with the datasourcekey it works #2 another related question: when I change that, everytime I run the project, a screen appears to select the data connection, why this happen? #3 question : If I set datasources manually (DataLayer.DataSources.Add(New SqlDataSourceItem("", "myconnectionstring")), can I avoid to display of any message of connectionmanager to the user of the compiled application? Can I override the connectionmanager and load a xml with my connectionstrings, read it and set datasource connections manually without any prompt? #4 question [not related to datasources] I created a custom field property (same as the tutorial) and try to filter with this field MyBo1.filter = "MycustomField = 'something'" I get a error like "the column [MyCustomField] cannot be found" question: Can I filter via a custom field? thanks for all the help
|
|
|
Fabian R Silva, -
|
|
Group: StrataFrame Users
Posts: 153,
Visits: 1.2K
|
about question #4 the post [url=http://forum.strataframe.net/Topic2952-9-1.aspx][/url] speak about create a extra column to internal data table, it´s ok or not apply? thanks
Post #2977
------------
Table 1 has InvtID
Table 1 has a calculated field (In the business object) that is a GUID that corrosponds to the Server/Database (ERPXrefKey). This is NOT a field in table 1, but is required for the correct entry in table2
Table 2 is in a different database
Key in Table2 is the ERPXrefKey and then InvtID
I'd like to form a business relationship with the calculated field and the key.
--------------------------------------------------------------------------
Post #2979
-----------
Ben Chase
Posted 09/22/2006 9:08:21 AM
Well, any time a business object needs to reference a field from the business object on the other side of the relationship, it uses the default property (indexer), which will return a value through any strong-typed property, not just the ones that are in the table. However, when the business objects attempt to do things such as cascading the row filter, or using the "FillByParent" methods, the business objects are expecting all of the fields to be part of the current data table and the table in the database. So, I'm not sure of a way around your problem other than to add an extra column to the internal data table of the business object each time the CurrentDataTableRefilled method fires and calculate the values for the extra column.
pd: attached a jpg with the popup that appears when I run the project (about question on previous post...)
Thanks again!
- Fabian
|
|
|
Fabian R Silva, -
|
|
Group: StrataFrame Users
Posts: 153,
Visits: 1.2K
|
Forgive about the popup that appears when I run the project, I forgive when I debug the connections' stuff a 'ConnectionManager.ShowAvailableConnectionStrings()' [ question #2 ]
|
|
|
StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
1) A data source with a DataSourceKey of "" is not required, but recommended. It's recommended because "" is the default DataSourceKey for business objects (and the DataSourceKey on the business object tells the business object which connection string to use). So, you don't have ot use "", but if you don't you'll need to change all of the DataSourceKey properties to match throughout your application. 2) You figured this one out 3) Yes, the manual option allows you to retrieve the connection string any way you want to. You don't have to use the ConnectionManager class at all. In fact, it's probably only recommended to use when have an internal application where your users will know their own connection string. So, just change the SetDataSources() method to add the connections manually and acquire the connection string any way you like. Then, just make sure you don't set any properties or call any methods on the ConnectionManager class (especially the ConnectionManager.SetConnections() method ). 4) Yes, the field must belong to the CurrentDataTable to be able to filter on it. So, if you add an additional column to the CurrentDataTable and populate that column, you'll be able to filter/sort on it. But, if you just have a custom field that does not have a backing column in the CurrentDataTable, you will not be able to sort/filter on it.
|
|
|
Fabian R Silva, -
|
|
Group: StrataFrame Users
Posts: 153,
Visits: 1.2K
|
3) Yes, the manual option allows you to retrieve the connection string any way you want to. You don't have to use the ConnectionManager class at all. (especially the ConnectionManager.SetConnections() method [Wink] ). I especially not call this method as you say and all work ok (I was thinked that this line cannot have to be supressed )
4) Yes, the field must belong to the CurrentDataTable to be able to filter on it. So, if you add an additional column to the CurrentDataTable and populate that column, you'll be able to filter/sort on it. But, if you just have a custom field that does not have a backing column in the CurrentDataTable, you will not be able to sort/filter on it. I don´t watched that I don´t need to use Currentview.table I called my "_ExtraColumnAdd" method after the fill method and voila!
Private Sub _ExtraColumnAdd()
'Me.CurrentView.Table.Columns.Add("ExtraColumnName", System.Type.GetType("System.String"), "")
Me.CurrentDataTable.Columns.Add("ExtraColumnName", System.Type.GetType("System.String"), "")
Dim row As DataRow
'For Each row In Me.CurrentView.Table.Rows
For Each row In Me.CurrentDataTable.Rows
'Some stuff to fill the new column here
row("ExtraColumnName") = "Voila!"
Next row
End Sub
later on my form I can use this column like another
It´s the best thing to do about add a new calculated field that can be filtered?Thanks Ben and Trent for all the support to learn all the stuff around Strataframe, you are awesome pd: Can I post a sample with a routine that recursively read a DB to fill a treeview on the contribution topic to read some feedback on what is wrong and what can I do in a better manner?
its used to create a tree menu like
1 : Module 1
1.1: ABMs
1.1.1: Customers
1.1.2: Employees / etc)
1.2: Configs
|
|
|