An error occurred while creating a new DataLayer for the business object


Author
Message
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
I'm glad I could help, sorry it took me a while to figure out the scenario Smile
Ricardo Quartier
Ricardo Quartier
StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)
Group: Forum Members
Posts: 87, Visits: 779
Dawn it.. Ben u are "..." good... now it works... i though the startup object must be the form... now it's understood...

Thanks again...

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
If it is still giving you the error within the FillTop100() method, and it is never showing the connection dialog, then somewhere, you calling the FillTop100() method before the DataSources are ever set.



It looks from the Stack Trace that you're not running through the AppMain.vb file at all. Check your project properties and make sure that the "Startup object" is set as "Sub Main." If you want you change the form that is launched at application startup, then you need to change the InitApplication() method within the AppMain.vb file.



Change:



e.Forms.Add(GetType(futebol.Form1))



to



e.Forms.Add(GetType(futebol.frmCadClubes))



and make sure that the Startup object is still "Sub Main"
Attachments
ProjectProperties.jpg (200 views, 71.00 KB)
Ricardo Quartier
Ricardo Quartier
StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)
Group: Forum Members
Posts: 87, Visits: 779

Hi, me again... I changed .... but still doesn't works ... Hehe

It compiles, but when i hit run.. it breaks on the BO code, that one on the pic, in the first post, same error, it doesn't show the connection screen anymore, can that help?

Below is where i changed...

ConnectionManager.ApplicationKey = "Cadastro de Clubes2"

ConnectionManager.ApplicationDefaultTitle = "ConexÆo do Cadastro de Clubes"

ConnectionManager.ApplicationDefaultDescription = "Esta conexÆo de aplicativo ‚ utilizada pela aplica‡Æo Cadastro de Clubes"


Ricardo Quartier
Ricardo Quartier
StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)
Group: Forum Members
Posts: 87, Visits: 779
OK, I´ll try

Thanks Ben......

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Do you have any code that is changing the MicroFour.StrataFrame.Data.DataLayer.DataSources collection? If you're not manually changing the collection, change this line within SetDataSources():



ConnectionManager.ApplicationKey = "Cadastro de Clubes"



to



ConnectionManager.ApplicationKey = "Cadastro de Clubes2"



The, run the application. It should show you the connection string wizard and after you configure the connection, you should be good to go...
Ricardo Quartier
Ricardo Quartier
StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)
Group: Forum Members
Posts: 87, Visits: 779
Crazy Still not worked... this is what a i done, and then the problem started.. I wanted to test dropdowns, so i add a new form.. form1 then i went to the:

Private Shared Sub InitApplication(ByVal e As InitializingApplicationEventArgs)

'-- Add the main form type

'-- If more than one form is added to the collection, they can be chosen by showing a "Gateway" form

' and supplying the index of the form to show (At least 1 form type must be added to the collection

e.Forms.Add(GetType(futebol.frmCadClubes))

And Changed the name of this form to the new form then i inserted the dropdown... then i changed in the startup object to the form1, i get the error, deleted the form1 one, changed back the InitApplication and the startup object.. below my Private Shared Sub SetDataSources() but i guess it's fine... so im still lost, is there any other way to help, do u have ny other clue?

Thanks,

Ricardo

''' <summary>

''' Gets the connection string if the application will use a custom method to aquire the connection

''' string rather than the StrataFrame Connection String Manager (optional)

''' </summary>

''' <remarks></remarks>

Private Shared Sub SetDataSources()


' ToDo: 1) Set the connection information below including the connection application settings and the

' required settings information and then call the ConnectionManager's SetConnections() method.

'

' OR

'

' 2) Manually set the DataSourceItems on the DataSources collection below.

' -- You can set as many data sources as necessary. The business objects use the data source specified

' by their DataSourceKey property (defaults to "").

'------------------------------------

' Using the Connection Manager

'------------------------------------

'-- Set the information specific to this application and the data sources

' The application key:

ConnectionManager.ApplicationKey = "Cadastro de Clubes"

ConnectionManager.ApplicationDefaultTitle = "ConexÆo do Cadastro de Clubes"

ConnectionManager.ApplicationDefaultDescription = "Esta conexÆo de aplicativo ‚ utilizada pela aplica‡Æo Cadastro de Clubes"

'-- Set the required data source information so that the ConnectionManager can gather it

' SQL Connection

ConnectionManager.AddRequiredDataSourceItem("", "SQL Connection", _

DataSourceTypeOptions.SqlServer, "futebol", "Esta conexÆo de aplicativo ‚ utilizada pela aplica‡Æo Cadastro de Clubes")

' Oracle Connection

'ConnectionManager.AddRequiredDataSourceItem("", "Oracle Connection", _

' DataSourceTypeOptions.Oracle, "", "This connection is used by WindowsApplication1.")

' Access Connection

'ConnectionManager.AddRequiredDataSourceItem("", "Access Connection", _

' DataSourceTypeOptions.MicrosoftAccess, "", "This connection is used by WindowsApplication1.")

' FoxPro Connection

'ConnectionManager.AddRequiredDataSourceItem("", "Visual Fox Pro Connection", _

' DataSourceTypeOptions.VisualFoxPro, "", "This connection is used by WindowsApplication1.")

'-- 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()

'------------------------------------

' Setting the data sources manually

'------------------------------------

'-- SQL Server

'DataLayer.DataSources.Add(New SqlDataSourceItem("", "myconnectionstring"))

'-- Oracle

'DataLayer.DataSources.Add(New OracleDataSourceItem("", "myconnectionstring"))

'-- Microsoft Access

'DataLayer.DataSources.Add(New AccessDataSourceItem("", "myconnectionstring"))

'-- Visual Fox Pro

'DataLayer.DataSources.Add(New VfpDataSourceItem("", "myconnectionstring"))

End Sub

Ricardo Quartier
Ricardo Quartier
StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)
Group: Forum Members
Posts: 87, Visits: 779
Hey, thanks Ben,i will take a look, if I cannot fix, I paste the code here...

About the avatar i tried a squirrel that fights Karate in a animated gif, but just the first frame appear, so it's not very animated in the forum, this one is the "logo" of São Paulo Futebol Clube, actual and 3 times soccer world champion. Very popular here in Brazil.

Best regards,

Ricardo

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Whenever you get an exception that says DataSourceKey [] was not defined, then the data source specified by the key in the brackets (in this case an empty string) does not exist in the DataLayer.DataSources collection. Most likely, either you forgot to create the data source, or the data source is under a different name. Check the SetDataSources() method in the AppMain.vb file and make sure that the data sources are being configured properly.



You can post the code in the SetDataSources() method and I'll take a look at it if you need me to.



P.S. Hey, I like your avatar Smile
Ricardo Quartier
Ricardo Quartier
StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)
Group: Forum Members
Posts: 87, Visits: 779
w00t Any clue, about how to solve this.. used to work.. ? Im lost....

Thanks in advance friends... I sent a screenshot of the debug too.... hope to help.....  BigGrin

MicroFour.StrataFrame.Data.DataLayerException was unhandled
  Message="An error occurred while creating a new DataLayer for the business object."
  Source="MicroFour StrataFrame Business"
  StackTrace:
       at MicroFour.StrataFrame.Business.BusinessLayer.get__DataLayer()
       at MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(String SelectStatement)
       at futebol.ClubesBO.FillTop100() in C:\Documents and Settings\Ricardo\Meus documentos\Visual Studio 2005\Projects\futebol_SF\futebol_SF\Business Objects\ClubesBO.vb:line 68
       at futebol.frmCadClubes.ClubesBO1_ParentFormLoading() in C:\Documents and Settings\Ricardo\Meus documentos\Visual Studio 2005\Projects\futebol_SF\futebol_SF\Forms\frmCadClubes.vb:line 4
       at MicroFour.StrataFrame.Business.BusinessLayer.raise_ParentFormLoading()
       at MicroFour.StrataFrame.Business.BusinessLayer.RaiseParentFormLoadingEvent()
       at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.InitializeFormLoadObjects()
       at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.BaseForm_Load(Object sender, EventArgs e)
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
       at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Control.set_Visible(Boolean value)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at futebol.frmCadClubes.Main() in C:\Documents and Settings\Ricardo\Meus documentos\Visual Studio 2005\Projects\futebol_SF\futebol_SF\Forms\frmCadClubes.Designer.vb:line 2
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

Attachments
exception.gif (204 views, 63.00 KB)
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search