StrataFrame Forum

Problem with Data retrival in BO

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

By justalex - 4/22/2007

I walked the tutorial and made it step by step also I made my own program and made some BO-s UniversityBO, FacultyBO ... the UniversityBO at the FillTop100 method gives me an error

My code is this:



Public Sub FillTop100()



Me.FillDataTable("SELECT TOP 100 * FROM Universitate")



End Sub



The error is this One SadI mention that I followed the standard procedure in making BO and mapping data - yesterday it was working fine )



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 ManagerUniversitate.UniversitateBO.FillTop100() in D:\5.MyDocuments\Visual Studio 2005\Projects\ManagerUniversitate\ManagerUniversitate\Libs\UniversitateBO.vb:line 69

at ManagerUniversitate.frmActualizareUniversitate.UniversitateBO1_ParentFormLoading() in D:\5.MyDocuments\Visual Studio 2005\Projects\ManagerUniversitate\ManagerUniversitate\Forms\frmActualizareUniversitate.vb:line 5

at MicroFour.StrataFrame.Business.BusinessLayer.raise_ParentFormLoading()

at MicroFour.StrataFrame.Business.BusinessLayer.OnParentFormLoading()

at MicroFour.StrataFrame.Business.BusinessLayer.RaiseParentFormLoadingEvent()

at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.InitializeFormLoadObjects()

at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.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 MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.SetVisibleCore(Boolean value)

at System.Windows.Forms.Control.Show()

at ManagerUniversitate.frmMainwindow.UniversitateToolStripMenuItem_Click(Object sender, EventArgs e) in D:\5.MyDocuments\Visual Studio 2005\Projects\ManagerUniversitate\ManagerUniversitate\Forms\frmMainwindow.vb:line 32

at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)

at System.Windows.Forms.ToolStripMenuItem.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.MenuStrip.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.UnsafeNativeMethods.DispatchMessageW(MSG& msg)

at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)

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 ManagerUniversitate.frmMainwindow.Main() in D:\5.MyDocuments\Visual Studio 2005\Projects\ManagerUniversitate\ManagerUniversitate\Forms\frmMainwindow.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()
By Ivan George Borges - 4/22/2007

Hi Alex.

I don't expect this to be, but you called your BO UniversityBO. Is your table called University? If so, you have put Universitate in the SQL statement.

By justalex - 4/22/2007

as much as I would love this to be the issue it is not Sad I don't know what is the problem if I make the exact same steps all over again it works but in that case it does not I even deleted the UniversitateBO and recreated it and the code and still nothing Sad ...
By justalex - 4/22/2007

also I see That this Message is given to me by all the Bo-s when I request their Data and I think that happened after I remapped the data with the BO Mapper strange thing is that I requested a Rebuild for all the bo-s ... any Ideas ?
By Trent L. Taylor - 4/23/2007

This problem should be a simple one to fix.  The message it is giving you indicates that you do not have the proper data access layer information setup in the AppMain.vb (or program.cs) file.  Open the AppMain.vb (or program.cs) file and go to the SetDataSources method.  If you are calling the Databasics.SetConnections() method then you will need to verify the AddRequiredDataSource statements above to verify that the correct database name has been provided.  This will not correct your problem but may give you a clue.  More than likley the ConnectionWizard has already run once and may not be coming up again, but the problem is that your connection string is invalid.

Just to test and make sure it is a connection issue, comment out the line that calls Databasics.SetConnections().  Below this line, manually add your connection string:

Databasics.DataSources.Add(New SqlDataSourceItem("","server=localhost;integrated security=SSPI;database=MyDatabase;"))

If this works, then you can put it back the way it was and then force the connection wizard to come back up so you can edit the connection string:

ConnectionManager.ShowAvailableConnectionStrings()

Calling this method will show all available connection strings for this application and allow you to modify the string.

Note: The database and tables must obviously exist within the server in which you are attempting to connect.  I know that you know this, but we have chased that rabbit before Smile

By StrataFrame Team - 4/23/2007

Is there an InnerException to that exception that you posted?  That exception generally occurs when the DataSource could not be found in the DataSources collection.  So, if the DataSourceKey for the business object is wrong, or the SetDataSources() method within the AppMain.vb (Program.cs) is wrong, then you'll get that exception. 

FYI, if you get that exception, let the method continue to run and you'll get the red exception dialog that will give you the InnerException.